Add Media for Contributor Role in WordPress CMS

Computer Skills PHP Tips & Tricks Web Development WordPress

I have multiple people adding content to this website, everyone is assigned to a contributor role. And of course, as the capabilities state, they were not able to add media to the articles they wrote. The text editor for them had the Add Media button missing.

Add New Post No Add Media

Now, not having this button will not only make the media management difficult for these writers but also be time-consuming. now there are two ways you can allow your contributors to have this capability to add media with the button click.

  1. Update functions.php file with a small code snippet
  2. Use plugin

Update functions.php file to Add Media

If you are just into blogging, use plugin to get this done

If you are a developer or have a bit of knowledge about coding, or if you are sure you can manage to add a code snippet to your WP child theme’s functions.php file, I would suggest you go with it. When you do this,

  1. You save a lot of time
  2. Avoid using a plugin for small tasks, thus no extra plugin to maintain

NOTE: Only if you are sure you wouldn’t mess up, do it! Do it in the child theme for being immune to theme updates.

You just need to add the following code snippet and you will be all done:

// Allow Contributors to Add Media
if ( current_user_can( 'contributor' ) && ! current_user_can( 'upload_files' ) )
    add_action( 'admin_init', 'sh_allow_contributor_uploads' );

function sh_allow_contributor_uploads() {
    $contributor = get_role( 'contributor' );
    $contributor->add_cap( 'upload_files' );

Save the file and you are all good to go.

Using Plugin to Add Media

If you are familiar with coding, add the code snippet in your functions.php file

If you are just a blogger, with no experience in coding, chose this to be on the safest side. You don’t need to worry about the theme updates as well.

There are numerous plugins out there for changing the user role capabilities. I will show to how to use the best and easiest one so far which is the User Role Editor plugin.

Follow the steps below and get your contributors ready!

  1. Install the User Editor Role Plugin
  2. Go to Users -> User Role Editor

    User Role Editor Option
  3. Select Contributor(contributor) for the Select Role and change its capabilities field

    Contributor Role

  4. Check the option for upload_files

  5. Hit Update

    Update User Role Setting

That’s all.

The contributor now needs to re-login to start writing articles with the Add Media button and accessibility to upload media. Your contributors can now see the editor which would look something like this:

Contributor Add Media

There you can see the option to upload media. Well done! Happy Blogging!