I would like to allow contributors to upload a file. So I use this recommended plugin WP Role Editor After activated, I go to the plugin from User > User Role Editor and then select contributor in the selection dropdown. After that I put a check on upload_files and hit update. Then, I login with contributor account to test uploading a file. Great, I see the media upload button but when I click to upload a file, I get this error:

Sorry, you are not allowed to attach files to this post

I posted a question about this in their support forums but the plugin author hasn't given a solution.

Now, I tried the code below that I've found in Google. However, it doesn't show the upload media button at all.

// Let Contributor Role to Upload Media
if( current_user_can( 'contributor' ) && ! current_user_can( 'upload_files' ) )
    add_action( 'admin_init', 'allow_contributor_uploads' );
    function allow_contributor_uploads() {
        $contributor = get_role( 'contributor' );
        $contributor->add_cap( 'upload_files' );

So, what else can I do to get this done? Why doesn't WordPress allow Contributor role to upload a files? According to the theme I use, I have to set this role by default for register users if I want users to submit a post with approval.

  • Roles have dependencies, so upload_files likely isn't enough, without seeing the full list of capabilities a contributor has and how yours differs from a normal contributor I don't know how this question can be answered easily. Do contributors have the edit_posts capability? – Tom J Nowell Feb 20 '18 at 16:27
  • Sure, you can see the screenshot dropbox.com/s/41bbphu1zm6b3y1/… – linpin Feb 20 '18 at 16:35
  • And you've checked upload_files? Have you contacted support for the WP Role Editor plugin? – Tom J Nowell Feb 20 '18 at 17:48
  • It seems that you didn't read my details at all. – linpin Feb 20 '18 at 17:50
  • I did read your details, I see that your screenshot doesn't show the upload_files checkbox so I can't see if you've enabled it in the plugin. I also saw your code, but I'm trying to ascertain if your code is even necessary, and if it's being overridden by the WP Roles Editor plugin – Tom J Nowell Feb 20 '18 at 22:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.