I want my editors to have the possibility, to add other users. I added:


to the functions.php - but now, the editors are also able to create, change an Admin Role.

Is there any way, to exclude admin from the roles?

Thank you!


1 Answer 1


Giving the capability to delete and edit users would compromise your security, as then the editors would have the ability to modify your profile too. What you could do is just give the create_users capability to the editors. But the users thus created would be allotted "Subscribers" role by deafult.

EDIT: Try the following code ( Requires a bit of testing / sort of a hack for your requirement )

if ( isset( $_REQUEST['user_id'] ) ) {
    $userdata = get_user_by( 'id', $_REQUEST['user_id'] );
    if ( isset( $userdata->roles[0] ) && ( 'administrator' == $userdata->roles[0] ) ) {
        $edit_editor->remove_cap( 'create_users' );
        $edit_editor->remove_cap( 'delete_users' );
        $edit_editor->remove_cap( 'edit_users' );
    } else {
        $edit_editor->add_cap( 'create_users' );
        $edit_editor->add_cap( 'delete_users' );
        $edit_editor->add_cap( 'edit_users' );
} else {
    $edit_editor->add_cap( 'create_users' );
    $edit_editor->add_cap( 'delete_users' );
    $edit_editor->add_cap( 'edit_users' );
  • Hi Joshua, thanks for the reply. Is there any way to make not "Subscribers" by default, but "Authors"? Maybe that would be just enough...
    – ad2003
    Jul 23, 2012 at 14:03
  • Just try the above edited answer and see if it fulfills the requirement Jul 23, 2012 at 15:05
  • thank you for your effort! I tried it, but it didn't work.
    – ad2003
    Jul 24, 2012 at 8:43
  • are you using $edit_editor = get_role('editor') to fetch the editor role? From the above code you should be able to assign any role to a new user but you can't edit existing users. Jul 24, 2012 at 9:51

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.