Cz Complete is Incomplete

Tips on how to Prohibit media information from Authors and Members in WordPress

Restrict media files for other users WP


By default, WordPress permits all authors and editors to view all downloaded information within the WordPress media library. In some circumstances, this generally is a drawback if there are a variety of visitor authors in your web site and you do not need them to see completely all of the information on the positioning.

On this lesson, we’ll present you the best way to conceal your downloaded media information from different authors and contributors in WordPress.

Why Prohibit information from different WordPress customers?

WordPress permits all customers of admin with creator rights to view all downloaded information within the library. Authors can even see all photos uploaded by directors and different authors and editors.

For instance, you might be an administrator and are getting ready a publication in regards to the launch of a brand new product on the positioning.

Any visitor creator of your web site can go to the Media Recordsdata part and see all the pieces that you just uploaded for this publication, thereby studying what confidential info is prone to be forward of time.

Additionally, all these downloads will likely be earlier than the eyes, if the creator merely downloads his content material – all earlier downloads will likely be seen within the file loader window.

For an everyday weblog, this is not going to be an issue. However if in case you have a number of authors on the venture, there could also be a necessity to cover info from outsiders (even authors).

Now we’ll present how simple it’s to do that on WordPress.

Technique 1. Prohibit Media Library Entry plugin

The simplest and most secure manner is to put in a free plugin Prohibit Media Library Entry from the WordPress listing:

restrict media libraryThe plugin works instantly out of the field, it doesn’t have any settings. Simply set up and activate it.

After activation, each time you entry the Media information, the plug-in will verify the entry stage of every consumer. If the consumer position is decrease than the Administrator or the Editor, the consumer will solely see their very own downloads within the library.

If the consumer is an Administrator or an Editor – he/she’s going to see all of the downloads as traditional.

Technique 2. Shut entry to Media information manually

Within the first methodology we allowed trying Directors and Editors in any respect information, and for everybody else restricted entry.

However if you wish to prohibit entry to the positioning information to just one explicit consumer position – you need to use the second handbook methodology.

To do that, add this code to the capabilities.php file of your energetic WordPress theme:

in case you are unsure verify custom code in WordPress without breaking something

 // Restrict media library entry
add_filter ('ajax_query_attachments_args', 'wpb_show_current_user_attachments');
operate wpb_show_current_user_attachments ($ question) {
    $ user_id = get_current_user_id ();
    if ($ user_id &&! current_user_can ('activate_plugins') &&! current_user_can (' edit_others_posts
')) {
        $ question ['author'] = $ user_id;
    return $ question;

This code makes use of the operate current_user_can to verify if the consumer with this position has the power to activate plug-ins and edit different individuals’s posts. If the consumer position doesn’t have such options, then the code restricts the show of information within the library solely by downloads of that specific consumer.

Leave A Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.