If you are running a multi-author WordPress blog, where a subset of users are with contributor role, by default WordPress users under contributor role are not allowed to upload any media content and Add Media button will not be visible to them. But this quite annoying, the user who wants to make his post more interactive, then they need to add some images/videos to the post. Today, I came with a simple tweak to enable Add Media button to contributors which Allow Contributors to Add Media in WordPress. This will be very helpful to the WordPress admins who are accepting guest posts from multi authors.
A simple 5 line of code will enable Add Media button to contributors. Let’s see the steps.
How To Steps:
- Administrators, Login to your WordPress admin panel.
- Then open functions.php file of your current WordPress theme in edit mode. You can go to functions.php page by navigating to Appearance > Editor and then choose functions.php.
- functions.php of your current theme will be available from the list of files under Templates menu on the right side on the Editor page. Here add the below snippet of code inside the functions.php file and click Update File.
Please find the snapshot of functions.php in WordPress Panel where I added the code.
/*Contributor Media Upload*/
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’);
}
Once you have updated the file. Your contributor now able to see the Add Media button on Posts page.
Note: If you are unfamiliar with editing the codes, please take a backup before you edit.
Happy Blogging !!!
If you have any doubts, feel free to leave a comment.