admin管理员组文章数量:1325236
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' );
本文标签: phpallow subscribers to see private posts without plug in
版权声明:本文标题:php - allow subscribers to see private posts without plug in 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742167529a2426105.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论