I created a new user role called "developer" and I gave it all of administrator's capabilities:
$admin_role = get_role( 'administrator' );
add_role( 'developer', __( 'Developer' ), $admin_role->capabilities );
This works great except I'd like Developers to be able to add/edit Administrator users. However, when I add a new user, "Administrator" isn't one of the options in the user role dropdown list.
I tried having the editable_roles filter return all of the roles in the system, so that the Developer can add/edit all roles:
add_filter( 'editable_roles', 'allow_developers_to_add_administrators' );
function allow_developers_to_add_administrators( $roles ){
$user = wp_get_current_user();
if( in_array( 'developer', $user->roles )){
return array_keys( $GLOBALS['wp_roles']->roles );
}
return $roles;
}
But when I do that, the roles dropdown list only shows the 1st letter of each role (they have a custom set of roles and this is showing the first letter for each one):
I also tried simply appending 'administrator' to the $roles returned from the editable_roles filter, but it - predictably - just added an item with 'a' to the dropdown list.
Anyone know how I can make this work? (Note that I'm not on multisite so I don't think there's a super admin role I can hook into here)
Thanks!
Abby