Add Media for Contributor Role in WordPress CMS
I have multiple people adding content to this website, everyone is assigned to a contributor role. And of course, as the capabilities state, they were not able to add media to the articles they wrote. The text editor for them had the Add Media button missing.
Now, not having this button will not only make the media management difficult for these writers but also be time-consuming. now there are two ways you can allow your contributors to have this capability to add media with the button click.
Update functions.php file to Add Media
If you are a developer or have a bit of knowledge about coding, or if you are sure you can manage to add a code snippet to your WP child theme’s functions.php file, I would suggest you go with it. When you do this,
- You save a lot of time
- Avoid using a plugin for small tasks, thus no extra plugin to maintain
NOTE: Only if you are sure you wouldn’t mess up, do it! Do it in the child theme for being immune to theme updates.
You just need to add the following code snippet and you will be all done:
// Allow Contributors to Add Media if ( current_user_can( 'contributor' ) && ! current_user_can( 'upload_files' ) ) add_action( 'admin_init', 'sh_allow_contributor_uploads' ); function sh_allow_contributor_uploads() { $contributor = get_role( 'contributor' ); $contributor->add_cap( 'upload_files' ); }
Save the file and you are all good to go.
Using Plugin to Add Media
If you are familiar with coding, add the code snippet in your functions.php file
If you are just a blogger, with no experience in coding, chose this to be on the safest side. You don’t need to worry about the theme updates as well.
There are numerous plugins out there for changing the user role capabilities. I will show to how to use the best and easiest one so far which is the User Role Editor plugin.
Follow the steps below and get your contributors ready!
- Install the User Editor Role Plugin
- Go to Users -> User Role Editor
- Select Contributor(contributor) for the Select Role and change its capabilities field
- Check the option for upload_files
- Hit Update
That’s all.
The contributor now needs to re-login to start writing articles with the Add Media button and accessibility to upload media. Your contributors can now see the editor which would look something like this:
There you can see the option to upload media. Well done! Happy Blogging!
No comment yet, add your voice below!