How to Hide Media or the “Add Media” Button in WordPress
When you give users access to your site’s editor, whether they’re freelancers, lower level team members, or even the general public, it might come at a cost.
One consistent concern in these situations is giving users access to the media library, or even allowing them to upload media at all.
Below we’ll go over a few ways to remedy those issues.
First, we’ll hide the “Add Media” button from lower level users altogether. And then we’ll go over a solution that will let users upload media, but they won’t be able to see or access media uploaded by others.
These solutions involve adding code to your functions.php file. (Appearance > Editor > Theme Functions – functions.php)
If doing this, you should consider creating a child theme.
Another option is to turn these bits of code into your own homemade plugin.
Hide “Add Media” Button from Non-Admins
Add the following code to your functions.php file. This will hide the button from all non-Admins.
If you’d like to allow Editors to see the button, you can change ‘manage_options’ to something that Editors have permission to do, such as ‘edit pages’.
Here you can see a before an after.
Thanks to David Kryzaniak for this.
Access Own Media Only
With this code, the Admin can see all the media. If you’d like to let Editors see all the media too, then you just need to change ‘manage_options’ to something that Editors have permission to do, such as ‘edit pages’.
Here we can see what the media library looks like for the Admin:
And here we can see what it looks like for an Author who has only uploaded one image for his own post:
Thanks to DLaverick on Stackflow for this.
Controlling Access to Media
And so there you go – two very convenient and simple ways to control access to media and the media library on your site.
Photo credit: collage de juventudTags: