Last active
August 29, 2015 14:03
-
-
Save ethanclevenger91/f5a2ed9c38413a73e95c to your computer and use it in GitHub Desktop.
Restrict media by user
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
function only_own_attachments($query) { | |
global $current_user; | |
if(is_admin() && !current_user_can('manage_options') && $query->query['post_type']=='attachment') { | |
$query->set('author', $current_user->id); | |
} | |
return; | |
} | |
add_action('pre_get_posts', 'only_own_attachments'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment