0

I need to remove user related capabilities(such as 'create_users', 'add_user', 'list_users', etc...) of an admin user.

I tested the code below in an 'init' method.

global $current_user;
get_currentuserinfo();
$current_user->remove_cap('create_users');
$current_user->remove_cap('add_user');
$current_user->remove_cap('list_users');

But I found that still user is able to access interface for managing user(even after refreshing many times). Is there any solution other than creating new role for this?

  • Do you want to remove this ability from all the admins in the site? or only for selected one(s)? – Maruti Mohanty Mar 4 '14 at 8:13
  • @Maruti Mohanty, only selected one(s). – Dipu R Mar 4 '14 at 9:08
0

Adapt the easier way. Install a plugin (Ex. Members) that can manage roles. Create one role with restricted access in your case a role with all the capabilities but not 'create_users', 'add_user', 'list_users',. Save this new role and assign it to the user you want to grant these restricted privileges.

  • thank you, but my site has lot of custom post types and a custom content publishing workflow are there, so it is difficult to integrate to existing system. Anyway thank you and are you sure that there is no way to remove pre-defined capabilities like 'create_users'?. – Dipu R Mar 4 '14 at 6:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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