Change WordPress user roles and capabilities › Forums › Restrict or Permit access inside WordPress – how to › How can i hide Other Roles dropdown menu from user editor, Grant Role button… › Reply To: How can i hide Other Roles dropdown menu from user editor, Grant Role button…
27/11/2018 at 11:09
#5311
whitenoise
Participant
Also I wanted to remove some (but not all) of the roles from the ‘Role’ box on the new user screen. I came across this code:
// Remove Administrator role from roles list
add_action( 'editable_roles' , 'hide_adminstrator_editable_roles' );
function hide_adminstrator_editable_roles( $roles ){
if ( isset( $roles['administrator'] ) && !current_user_can('level_10') ){
unset( $roles['administrator'] );
// add more unset rules here for your user roles
}
return $roles;
}
Which does the job perfectly if it helps anyone else.