Skip to content

Instantly share code, notes, and snippets.

@tsbega
Forked from ofernandolopes/functions.php
Created July 20, 2017 21:35
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 tsbega/3364f0f6e39cc79484282dce13c2ad58 to your computer and use it in GitHub Desktop.
Save tsbega/3364f0f6e39cc79484282dce13c2ad58 to your computer and use it in GitHub Desktop.
Limit Authors to their Own Posts in WordPress Admin
function posts_for_current_author($query) {
global $pagenow;
if( 'edit.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', 'posts_for_current_author');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment