WordPress – Allow Contributors to Add / Upload Media

In WordPress by default the Add Media functionality (called Capability in wordpress terms) is disabled for users with Contributor role. If you are hosting multiuser wordpress site where users with contributor roles logs in and update their post, they would not be able to add images / medias. That’s quite annoying. The user who is editing a post must be able to add supported media for their post.

Check below screenshot. The current user has “Contributor” role. Hence she is not able to view Add media button.

wordpress-contributor-add-media-disabled

Now to overcome this there is a simple trick. By using WordPress’s add_cap method we can add different capabilities to user. So we can add upload_files capability to a Contributor using this method.

Add following code in functions.php file of your current wordpress theme.

//Allow Contributors to Add 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');
}

Now logout and login again using a user with contributor role. Ta’da.. Add media button is visible now.

wordpress-contributor-add-media-option-enabled

Use this simple trick to make Add media button visible for contributors on your wordpress site. I think this simple trick will help those who have contributors on their site.

Get our Articles via Email. Enter your email address.

You may also like...

8 Comments

  1. Gaurav says:

    Where are you man? After long time?

    • Viral Patel says:

      Hi Gaurav, Ya long time :-) will call you soon.. Thanks for the comment.

  2. sathishw.r says:

    Thanks for Sharing the Information.

  3. Zopfeed says:

    Thanks a lot for this, it was super simple!

  4. Worked like a charm! Thanks for the knowledge and for taking the time to make the post.

  5. Miflon says:

    W 10,
    WP Version: 4.4.1
    WPMU: No
    MySQL Version: 5.6.26
    PHP Version: 5.5.30
    WP URL: http://localhost/wordpress
    plugins :
    All In One WP Security 4.0.3
    Contact Form 7 4.3.1 http://contactform7.com/
    Disable Password Reset 1.0
    Really Simple CAPTCHA

    I put that code in a plugin and I caught an issue and that comment :
    Fatal error:call to undefined function wp_get_current_user() in \wp-includes\capabilities.php on line 424
    I code in a local environment and that code put in functions.php works fine.

  6. Alan Levine says:

    This code is no good — current_user_can(‘contributor’) is not valid, you need to add a capability, not a role name.

    Better off using a plugin like https://wordpress.org/plugins/capability-manager-enhanced/

  7. Jimmy Moedjahedy says:

    Wow…Work perfectly for me, thanks mate…

Leave a Reply

Your email address will not be published. Required fields are marked *