admin管理员组文章数量:1122846
I've created a custom role via add_role
, it's in my activation hook and is being removed on deactivation, thus I'm deactivating and reactivating my plugin to see the role permission changes. I can see that the changes are appearing (I've used the User Roles and Capabilities plugin to check) but I still can't view private page and posts when logged in.
add_role( 'clerk', 'Clerk', [ 'read' => true, 'read_private_pages' => true, 'read_private_posts' => true ] );
I've even tried adding some other permissions and see straight away that the user is able to do the things so am sure that I'm adding permissions in the correct way.
So why can my Clerk user still not see private posts and pages? What am I missing, do they need some other permission in order for it to work?
I've created a custom role via add_role
, it's in my activation hook and is being removed on deactivation, thus I'm deactivating and reactivating my plugin to see the role permission changes. I can see that the changes are appearing (I've used the User Roles and Capabilities plugin to check) but I still can't view private page and posts when logged in.
add_role( 'clerk', 'Clerk', [ 'read' => true, 'read_private_pages' => true, 'read_private_posts' => true ] );
I've even tried adding some other permissions and see straight away that the user is able to do the things so am sure that I'm adding permissions in the correct way.
So why can my Clerk user still not see private posts and pages? What am I missing, do they need some other permission in order for it to work?
Share Improve this question asked Apr 6, 2022 at 15:56 Kevin NugentKevin Nugent 5631 gold badge8 silver badges20 bronze badges 2 |1 Answer
Reset to default 0Try to add a capability after you adding a rule:
add_role( 'clerk', 'Clerk', [ 'read' => true, 'read_private_pages' => true, 'read_private_posts' => true ] );
$role = get_role( 'clerk' );
$role->add_cap( 'read_private_posts' );
Work for me
本文标签: permissionsCustom Role readprivateposts Not Working
版权声明:本文标题:permissions - Custom Role read_private_posts Not Working 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736310320a1934334.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
read_private_posts
does not grant back-end access. – vancoder Commented Apr 6, 2022 at 20:56