Skip to content

Instantly share code, notes, and snippets.

@phpbits
Last active October 23, 2015 08:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phpbits/42f368b5fd9456307476 to your computer and use it in GitHub Desktop.
Save phpbits/42f368b5fd9456307476 to your computer and use it in GitHub Desktop.
Hide Post & Images
<?php
function hide_posts_media_by_other($query) {
global $pagenow;
if( ( 'edit.php' != $pagenow && 'upload.php' != $pagenow ) || !$query->is_admin ){
return $query;
}
if( !current_user_can( 'manage_options' ) ) {
global $user_ID;
$query->set('author', $user_ID );
}
return $query;
}
add_filter('pre_get_posts', 'hide_posts_media_by_other');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment