Stefan Baumgartner

Web ops, performance and front-end

Show only user's posts in post overview

30 December 2014 by @ddprrt | Posted in: 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

Comments? Shoot me a tweet!