fine-grained capabilities for user related capabilities

When we want to adjust users capabilities, we can do so quite fine-grained. For example we can configure that a certain

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 and
  • promote_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 administrators. 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).

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745673728a4639559.html

相关推荐

  • fine-grained capabilities for user related capabilities

    When we want to adjust users capabilities, we can do so quite fine-grained. For example we can configure that a certain

    5小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信