Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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