HomeArticles

Show only user's posts in post overview

Wordpress

This one restricts authors to only view their own posts in Wordpress’ post overview:

function mypo_parse_query_useronly( $wp_query ) {
if ( strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/edit.php' ) !== false || strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/upload.php' ) !== false ) {
if ( !current_user_can( 'update_core' ) ) {
global $current_user;
$wp_query->set( 'author', $current_user->id );
}
}
}

add_filter('parse_query', 'mypo_parse_query_useronly' );

Add this part to your functions.php or include it in a seperate plugin

Related Articles