0

I would like to turn off Media Library for the entire website and instead have the Wordpress to use DB to store media for every unique add. How do I do it?

Edit:

The issue that I am trying to resolve is that I don't want clients to interact with media library.

3
  • 1
    But all media is stored as an entry in the WP database, with references to the actual file location of the media item. AFAIK, you can't store media inside a database, just references to it. So I am confused (not an unusual occurence). Jul 21, 2019 at 23:39
  • The issue that I am trying to resolve is that I don't want clients to interact with media library.
    – Alex
    Jul 22, 2019 at 3:42

1 Answer 1

1

I did a googles of the issue (using 'wordpress restrict media access') and got this link on the first page https://www.wpbeginner.com/plugins/how-to-restrict-media-library-access-to-users-own-uploads-in-wordpress/

Which has this code

// Limit media library access

add_filter( 'ajax_query_attachments_args', 'wpb_show_current_user_attachments' );

function wpb_show_current_user_attachments( $query ) {
    $user_id = get_current_user_id();
    if ( $user_id && !current_user_can('activate_plugins') && !current_user_can('edit_others_posts
') ) {
        $query['author'] = $user_id;
    }
    return $query;
} 

If the user doesn't have post edit or admin capability, then they won't see anything on the Media screen in Admin. You can modify the code to check for a specific user group (admin only, for example), or a specific user.

There are other solutions found via the same googles/bing/duck search.

2
  • Thank you, I'll try!
    – Alex
    Jul 22, 2019 at 17:01
  • No problem. I learn everything from the googles. (BTW, if the answer matches your question, use the checkmark to vote it as the answer. That's the common procedure around here. The up arrow thing is to vote up an answer to somebody else's question because it was helpful to you.) Jul 22, 2019 at 20:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.