WordPress – Allow Contributors to Add / Upload Media

In WordPress by default the Add Media functionality (called Capability in wordpress terms) is disabled for users with Contributor role. If you are hosting multiuser wordpress site where users with contributor roles logs in and update their post, they would not be able to add images / medias. That’s quite annoying. The user who is editing a post must be able to add supported media for their post.


Check below screenshot. The current user has “Contributor” role. Hence she is not able to view Add media button.


wordpress-contributor-add-media-disabled


Now to overcome this there is a simple trick. By using WordPress’s add_cap method we can add different capabilities to user. So we can add upload_files capability to a Contributor using this method.


Add following code in functions.php file of your current wordpress theme.



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

Now logout and login again using a user with contributor role. Ta’da.. Add media button is visible now.


wordpress-contributor-add-media-option-enabled


Use this simple trick to make Add media button visible for contributors on your wordpress site. I think this simple trick will help those who have contributors on their site.


The post WordPress – Allow Contributors to Add / Upload Media appeared first on ViralPatel.net.








via ViralPatel.net http://ift.tt/1CO56nL

No comments:

Post a Comment

If you have any question please let me know

Windows 11 Insider Preview Build 29558.1000 Released to New Canary Channel

UPDATE: Windows 11 Insider Preview build 29558.1000 released to the new Canary channel. Windows Insiders on the refreshed Canary Channel wil...