0

I would like to allow contributors to upload media by using the following code added to functions.php. But the Add Media Button still doesn't show up.

//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');
}
0

Try changing current_user_can('contributor') to current_user_can('edit_posts'). According to the Codex, 'Passing role names to current_user_can() is discouraged as this is not guaranteed to work correctly.'

  • Thanks, but it's still not working. – dekkapo khonjon Jan 5 '18 at 6:35
  • Then I would try surrounding your conditional expression in brackets, just to make sure it's getting parsed properly: – Gary D Jan 5 '18 at 7:21
0

I would try surrounding your conditional expression in brackets, just to make sure it's getting parsed properly:

if ( current_user_can('edit_posts') && ! 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'); }

  • No, not working for me. You can try at your side. – dekkapo khonjon Jan 5 '18 at 9:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.