Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jstask82/86c522991413dfc0b76fffce62a6a3c3 to your computer and use it in GitHub Desktop.
Save jstask82/86c522991413dfc0b76fffce62a6a3c3 to your computer and use it in GitHub Desktop.
you ned to disable list view for this to work, use adminimize!
add_filter( 'ajax_query_attachments_args', 'wpb_show_current_user_attachments' );
function wpb_show_current_user_attachments( $query ) {
$user_id = get_current_user_id();
//has the capability to activate plugins or edit other user’s posts? if not limit files to users id
if ( $user_id && !current_user_can('activate_plugins') && !current_user_can('edit_others_posts
') ) {
$query['author'] = $user_id;
}
return $query;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment