I’am creating WordPress function for editing role name
function change_role_name($role_name, $new_role_name, $display_name) {
global $wp_roles;
if ( ! isset( $wp_roles ) )
$wp_roles = new WP_Roles();
$role =& get_role($role_name);
$wp_roles->roles[$role]['name'] = $new_role_name; //not working for sa
$wp_roles->role_names[$role] = $display_name;
}
problem here it don’t change the role label name
Those names are stored in the option
wp_user_roles
in the database tablewp_options
.So, the following will change the name of the
subscriber
role:Apparently, this is harmless, but caveat emptor…
In your code,
$wp_roles->roles[$role]['name'] = $new_role_name;
doesn’t work because it should be:And
$display_name
doesn’t make much sense.