1

Is it possible to add an individual capability to a user account in modern versions of WordPress (4.6.1)? Or are roles the only thing that "admin manageable" for user accounts?

If it is possible, where in the admin can you do this?

5
  • You mean add capabilities to a specific user? codex.wordpress.org/Function_Reference/add_cap Sep 26, 2016 at 20:40
  • @AhmedMahdi Thank you, yes, I meant capabilities (fixed in the post text). The link you provided shows how to programmatically add a capability to a user -- however, it looks like that adds the capability programmatically. I looking for an Admin UI feature that allows you to assign capabilities -- similar to how other systems allow you add individual ACL rules to a user account. Sep 26, 2016 at 22:00
  • Have you tried this plugin? wordpress.org/plugins/user-role-editor Sep 26, 2016 at 22:00
  • @AhmedMahdi Does you recommendation of a plugin mean there's no way in a stock wordpress install to get this granular level of permission control? Sep 27, 2016 at 16:36
  • 1
    Only programmatically. You can add, remove, edit capabilities programmatically. WP provides no interface to edit the user caps without the help of a 3rd party plugin, same for user roles. Sep 27, 2016 at 16:37

3 Answers 3

1

No there isn't anything built into the core WordPress, I would recommend this plugin: https://wordpress.org/plugins/user-roles-and-capabilities/screenshots/

Or you would use PHP to add a capability to a specific role (or user): https://codex.wordpress.org/Function_Reference/add_cap

0

No, there's no built-in feature for this (as of 4.6.1).

The best plugin I've found (and use) is called, Members.

Then instead of changing caps at the user-level, you'd use the plugin to:

  • Create a new role
  • Add the capabilities to that role
  • Assign user(s) to that role

Much easier to manage and maintain.

2
  • Does you recommendation of a plugin mean there's no way in a stock wordpress install to get this granular level of permission control? Sep 27, 2016 at 16:36
  • What @Ahmed said above. Programmatically or a plugin.
    – cowgill
    Sep 28, 2016 at 1:30
0

Add this code to functions PHP, and remove it after adding the cap.

Get User via get_user_by() you can use the ID, slug, email, or login info of the user. Our cap is "manage_xyz" in this example. 5 is the user id of the user you want to add cap.

 $my_user = get_user_by('ID',5);
     if (!$my_user->has_cap('manage_xyz')) {
        $my_user->add_cap('manage_xyz');
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.