I do not want another plug in but rather want to create custom code that will allow a logged in subscriber to view private posts. I want them to be able to view all private posts, not only their own.
I have found this below online but dont know what white spider is and dont trust it. What would I edit or modify here to make this my own?
function none(){
$subRole = get_role( 'subscriber' );
$subRole->add_cap( 'read_private_posts' );
$subRole->add_cap( 'read_private_pages' );
}
add_action( 'init', 'ws_private_posts_subscribers' );
I do not want another plug in but rather want to create custom code that will allow a logged in subscriber to view private posts. I want them to be able to view all private posts, not only their own.
I have found this below online but dont know what white spider is and dont trust it. What would I edit or modify here to make this my own?
function none(){
$subRole = get_role( 'subscriber' );
$subRole->add_cap( 'read_private_posts' );
$subRole->add_cap( 'read_private_pages' );
}
add_action( 'init', 'ws_private_posts_subscribers' );
Share
Improve this question
asked Aug 22, 2020 at 3:19
TedTed
435 bronze badges
1 Answer
Reset to default 1This can be added as a basic hook -
function what-ever-youwantto-callthis() {
$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
}
add_action( 'init', 'what-ever-youwantto-callthis' );