I’d like to restrict authors ability to see files uploaded by other users because this causes no end of trouble, since they can change captions etc.
I tried this code from here How to hide media uploads by other users in the Media menu?
add_action('pre_get_posts','users_own_attachments');
function users_own_attachments( $wp_query_obj ) {
global $current_user, $pagenow;
if( !is_a( $current_user, 'WP_User') )
return;
if( 'upload.php' != $pagenow )
return;
if( !current_user_can('delete_pages') )
$wp_query_obj->set('author', $current_user->id );
return;
}
This only works on the media screen, not when you select a file on a post to actually upload.
I also tried the second solution, but it’s causing issues with my autocomplete search function and I can’t figure out why.
Is there a way to stop authors seeing others files when they’re making a post?
Not tested, but maybe you can just extend the
$pagenow
check?Instead of â¦
⦠try â¦
That should cover the post editor screens too.