In normal WordPress use, you don’t check for roles, you check for capabilities. If you want to check if someone is at least an editor, you check current_user_can( 'edit_others_posts' )
. So, something like this:
add_filter( 'relevanssi_post_ok', 'rlv_member_check', 10, 2 );
function rlv_member_check( $post_ok, $post_id ) {
// An array of post IDs that only editors can access.
// This can be created manually like this or automatically, whatever is your criteria.
$editor_posts = array( 1, 2, 3, 4 );
$post = get_post( $post_id );
if ( in_array( $post_id, $editor_posts ) && ! current_user_can( 'edit_others_posts ' ) ) {
// Post is among the editor posts, and the user is not an editor.
$post_ok = false;
}
return $post_ok;
}
Now, I don’t know Members affects this. If it just offers an easy way to extend the WordPress roles and capabilities system, you’d do it like this, but if it’s something else, then you need to replace current_user_can()
with whatever works with Members. The Members support forums will help you with that.