0

I'd like to restrict users to only see/manage only their own uploads. However, there's a requirement to allow one than one account to manage these uploads. It cannot just be the person who originally uploaded them.

Is this possible?

1 Answer 1

0

Add this code in your Functions.php. This code help you to show user only their own uploads but admin can see all media uploaded by other users and this code is tested on current wordpress Version 5.8

// 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;
} 
1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Sep 14, 2021 at 9:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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