Skip to content

Instantly share code, notes, and snippets.

@trueqap
Created January 9, 2018 14:40
Show Gist options
  • Save trueqap/9d2f06eac165414550bb37cc365761c4 to your computer and use it in GitHub Desktop.
Save trueqap/9d2f06eac165414550bb37cc365761c4 to your computer and use it in GitHub Desktop.
<?php
function posts_for_current_author($query) {
global $pagenow;
if( 'edit.php' != $pagenow || !$query->is_admin )
return $query;
if( !current_user_can( 'edit_others_posts' ) ) {
global $user_ID;
$query->set('author', $user_ID );
}
return $query;
}
add_filter('pre_get_posts', 'posts_for_current_author');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment