Rename Roles Without Changing Them
Changes the names roles show on the Users screen and in role menus, for example "Subscriber" to "Member", without touching capabilities or the database.
Opens WPIDE on
Code
// Role ID => new name.
$wpide_role_labels = array(
'subscriber' => 'Member',
'contributor' => 'Guest Writer',
);
$wpide_role_rename = function ( $roles ) use ( $wpide_role_labels ) {
if ( ! $roles instanceof WP_Roles ) {
return;
}
foreach ( $wpide_role_labels as $role => $label ) {
if ( isset( $roles->roles[ $role ] ) ) {
$roles->roles[ $role ]['name'] = $label;
$roles->role_names[ $role ] = $label;
}
}
};
$wpide_role_rename( wp_roles() );
add_action( 'wp_roles_init', $wpide_role_rename );
Notes
Only the label changes; role IDs such as subscriber stay the same, so plugins keep working.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.