Last active
January 26, 2023 06:34
-
-
Save rubelmiah/ba203464c0156e93c67d3e87757f9c5a to your computer and use it in GitHub Desktop.
Besides administrator show only the current user media files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Besides administrator show only the current user media files | |
function show_current_user_attachments( $query ) { | |
if ( ! current_user_can('administrator') ) { | |
$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' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment