How to make WordPress ‘editor’ role to list/view/add/edit users only with the role ‘author’?
I have added some extra capabilities to the existing ‘editor‘ role in wordpress with:
function add_uedit_caps() {
$role = get_role('editor');
$role->add_cap('create_users');
$role->add_cap('list_users');
$role->add_cap('add_users');
$role->add_cap('edit_users');
}
add_action('admin_init', 'add_uedit_caps');
This piece works fine.
ISSUE:
The above code works to list and view all types of users by the ‘editor’. But if a new user added by the ‘editor’, it takes up the ‘new user default role’ set up in wordpress (reference), ie the role set in settings > general. No role change option is available too in the user edit mode.
I want the ‘editors‘ to list/view/add/edit only the users with the role ‘author‘. How can I achieve this through code (a method or class with action) and WITHOUT any plugin or tampering the core files?
Leave an answer
You must login or register to add a new answer .