Post visibility on the basis of roles

Give your custom roles the capability to “read_member_posts” or whatever. Then you could apply a filter to the_content()

add_filter( 'the_content', 'my_wpse20347_filter' );

function my_wpse20347_filter( $content )
{
    global $post;
    if( author_can( $post->ID, 'edit_posts' ) || current_user_can( 'read_member_posts' ) )
    {
       return $content;
    }
    else
    {  // Everyone else sees this in place of the content.
       return '<p>Only members may view this post</p>';
    }
}

Leave a Comment