MilesWeb Hosting Forum

Web Hosting Technical Support => How To's => Topic started by: Turkey on January 15, 2018, 04:42:18 PM

Title: How to allow contributors to add images in WordPress?
Post by: Turkey on January 15, 2018, 04:42:18 PM
In WordPress the user "contributor" can add content but cannot upload images using "add media" button. To allow such users to add images, add the below snippet in your themes functions.php file. You can add the code at the end of the file before the tag ?>

Code: [Select]

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