Hi, if I use the generic “subscriber” role, this code grants my subscriber user access to private posts. However, when I try to do the same for s2member_level1 (everything else on my site relies on the s2 member levels), then the user does not have access. This is in my child theme functions.php file:
Hoping Ijust have syntax wrong for referencng s2 member level:
function prc_subscribers_can_read_private_posts() {
$subRole = get_role( 'subscriber' ); //change the name of the user here
$subRole->add_cap( 'read_private_posts' ); //allows the above to read posts
$subRole->add_cap( 'read_private_pages' ); //allows the above to read pages
$subRoleL1 = get_role("s2member_level1"); //change the name of the user here
$subRoleL1->add_cap( 'read_private_posts' ); //allows the above to read posts
$subRoleL1->add_cap( 'read_private_pages' ); //allows the above to read pages
}
add_action( 'init', 'prc_subscribers_can_read_private_posts' );