Skip to content

Instantly share code, notes, and snippets.

@Asikur22
Last active December 31, 2019 12:45
Show Gist options
  • Save Asikur22/2da797a169d7003de294ef7ddbbec58b to your computer and use it in GitHub Desktop.
Save Asikur22/2da797a169d7003de294ef7ddbbec58b to your computer and use it in GitHub Desktop.
[Only Show Current User’s Media/Attachments] #Media
/*
* Only Show Current User's Media Attachments
*/
function show_current_user_attachments( $query ) {
$user_id = get_current_user_id();
if ( $user_id ) {
$query[ 'author' ] = $user_id;
}
return $query;
}
add_filter( 'ajax_query_attachments_args', 'show_current_user_attachments', 10, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment