joerga
Forum Replies Created
Viewing 1 replies (of 1 total)
-
I have the exact same problem. I solved it by this code in my functions.php:
if ( current_user_can('subscriber') && !current_user_can('upload_files') ) add_action('admin_init', 'allow_subscriber_uploads'); function allow_subscriber_uploads() { $subscriber = get_role('subscriber'); $subscriber->add_cap('upload_files'); }That worked as I wanted it but it is still not possible to upload images in the frontend. I still get the error “Sorry, you are not allowed to attach files to this post.”.
Uploading in the backend works fine but I want it to be as easy as possible for my users so I need this feature in the frontend too.
I get it that it is a problem with the roles so I already tried this after a lot of google research:
if ( current_user_can('subscriber') && !current_user_can('upload_files') ) add_action('admin_init', 'allow_subscriber_uploads'); function allow_subscriber_uploads() { $subscriber = get_role('subscriber'); $subscriber->add_cap('upload_files'); $subscriber->add_cap('edit_attachments'); $subscriber->add_cap('edit_posts'); $subscriber->add_cap('edit_published_pages'); $subscriber->add_cap('edit_others_pages'); $subscriber->add_cap('edit_others_posts'); $subscriber->add_cap('level_0'); $subscriber->add_cap('level_1'); }But it still doesn’t work and I think that’s way too much roles.
Any suggestions what to do?
Viewing 1 replies (of 1 total)