I need to forbid or deny a custom administrator role from creating other administrator user role

Question

What can I add to this code? … I need to forbid or deny this custom administrator role from creating other administrator user role?
thank you

add_action('init', 'cloneRole');

function cloneRole() {
 $adm = get_role('administrator');
 $adm_cap= array_keys( $adm->capabilities ); //get administator capabilities
 add_role('new_role', 'My Custom Role'); //create new role
 $new_role = get_role('new_role');
  foreach ( $adm_cap as $cap ) {
   $new_role->add_cap( $cap ); //clone administrator capabilities to new role
  }
}
?>
0
, Sea_pearl 2 years 2019-10-22T11:35:27-05:00 0 Answers 56 views 0

Leave an answer

Browse
Browse