I am setting up a site where there will be multiple users as Author, the owner doesn’t want the authors to be able to view each others posts, since there are some meta fields with information he’d rather not have shared between the authors.

Is there a way to remove the ability to view other authors posts?

Thanks,
Chuck

To clarify a bit more, this is for the admin side, at the top underneath Posts, there are links for mine, all, and published. I only want Authors to see “mine”.

5 s
5

If you want to prevent a user with the “Author” role to view other users’ posts in the overview screen (they won’t be able to view the details anyway), you can add an extra filter on the author:

add_action( 'load-edit.php', 'wpse14230_load_edit' );
function wpse14230_load_edit()
{
    add_action( 'request', 'wpse14230_request' );
}

function wpse14230_request( $query_vars )
{
    if ( ! current_user_can( $GLOBALS['post_type_object']->cap->edit_others_posts ) ) {
        $query_vars['author'] = get_current_user_id();
    }
    return $query_vars;
}

The little links above the post table (“Mine”, “All”, “Drafts”) are less useful now, you can also remove them:

add_filter( 'views_edit-post', 'wpse14230_views_edit_post' );
function wpse14230_views_edit_post( $views )
{
    return array();
}

Tags:

Leave a Reply

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