admin管理员组文章数量:1435859
When we want to adjust users capabilities, we can do so quite fine-grained. For example we can configure that a certain user can edit posts. But furthermore we can limit the capability of editing posts only to particular post types (eg cap: edit_posts
, edit_pages
, edit_[post_type]
). And even from there on we can go deeper and do thinks like only edit private posts of post types (eg cap: edit_private_posts
, edit_private_pages
); just to make sure what I mean with "fine-grained".
But when it comes to user related capabilities I'm only aware of exactly 6 capabilities, namely:
edit_users
,delete_users
,create_users
,list_users
,remove_users
andpromote_users
.
So this is it? What about: edit_editor_users
(which would mean: only edit users with user role "editor"). I can't believe that the user related capabilities are really that basic!
When I deliver a WP site to a customer I normally don't give them access to a user with user role administrator
but more likely something like editor
or custom user roles as well. But when I want to allow a user role to create users than users with that role can create users with each and every user role even administrator
s. Which would not be a good thing at all! So again. I need something like:
$role = get_role('editor');
$role -> add_cap('create_editor_users', true); // or in general:
$role -> add_cap('[edit|delete|create|list|remove|promote]_[user_role]_users', true);
Is there a non hacky way to achieve this? A Plugin would be also fine as well (by now I'm using "Members", which also only handles the 6 mentioned above).
本文标签: finegrained capabilities for user related capabilities
版权声明:本文标题:fine-grained capabilities for user related capabilities 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745673727a2669724.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论