Main Content

Give WordPress Contributors the ability to upload media.

WordPress CodeWordPress’ default roles are nice, but they are a bit limited. For example, if you’re listed as a Contributor you can write posts, but you can’t add media.

To add media, you need to be an author. At the author level, however, the user gets the ability to publish posts. That’s not good when someone wants to review them before they go out.

The good news is that there are a few lines of code you can drop into your functions.php file that will allow Contributors to upload images.


<?php
/**
* Allow the Contributor role to upload files.
*/
function add_theme_caps() {
$role = get_role( 'contributor' );
$role->add_cap( 'upload_files' );
}
add_action( 'admin_init', 'add_theme_caps');

If you want, line 5 ‘contributor’ can be replaced by any other role and line 6 ‘upload_files’ can be replaced with any other capability if you want to change things up a bit.

This code comes straight from WordPress and has worked well for me.


3 Responses

  1. Nazar says:

    Thanks! Worked for me! ;o)

  2. Dhimas says:

    Thank you very much!

  3. avinashwp says:

    Thanks, this works well for our site. Looking for the similar solution for many days.

Leave a Reply