WordPress’ 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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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.
Thanks! Worked for me! ;o)
Thank you very much!
Thanks, this works well for our site. Looking for the similar solution for many days.