Show Authors Their Own Posts in Admin

You can redirect the normal All Posts pages to a version that only displays the current user’s posts. (Similar to this post). Users will not be able to get back to the ‘all’ view, as in the other sample. Users are not prevented from changing the author ID in the URL and viewing another user’s posts.

add_action( 'load-edit.php', 'posts_for_current_author' );
function posts_for_current_author() {
	global $user_ID;

	/*if current user is an 'administrator' do nothing*/
	//if ( current_user_can( 'add_users' ) ) return;

	/*if current user is an 'administrator' or 'editor' do nothing*/
	//if ( current_user_can( 'edit_others_pages' ) ) return;

	if ( ! isset( $_GET['author'] ) ) {
		wp_redirect( add_query_arg( 'author', $user_ID ) );
		exit;
	}

}

2 thoughts on “Show Authors Their Own Posts in Admin”

  1. In the backend, how can I restrict the editors (editor role) from viewing/editing pages created by admin (and/or by admin role)?

  2. Perhaps you should add the beginning of comment tag within the script. The ending of comment tag indicates that you wanted to add “multi-line” comment tag which should be something like this /* your comment */. With this script, surely you would get an error or simply it won’t work. Thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: