最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - allow subscribers to see private posts without plug in

programmeradmin0浏览0评论

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
Add a comment  | 

1 Answer 1

Reset to default 1

This 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' );
发布评论

评论列表(0)

  1. 暂无评论