Created
December 3, 2019 05:20
-
-
Save zhonmaz/26c2ea701ced0a06ec403e1b8842a7ad to your computer and use it in GitHub Desktop.
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
// 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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment