Skip to content

Instantly share code, notes, and snippets.

@miziomon
Last active August 29, 2015 14:21
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 miziomon/f0d801bd067be64dfe31 to your computer and use it in GitHub Desktop.
Save miziomon/f0d801bd067be64dfe31 to your computer and use it in GitHub Desktop.
WordPress - Filter content by current user
/*
* @miziomon
* Filter content by current user
*
*/
add_filter('pre_get_posts', function ($query) {
global $pagenow, $user_ID;
if( !current_user_can('administrator') && $query->is_admin && 'upload.php' != $pagenow ){
$query->set('author', $user_ID);
}
return $query;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment