Is there way to rename user role name without plugin?

The question:

Is there anyway to rename a user role name via hook, instead of using plugin?


For example, administrator » owner

The Solutions:

Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.

Method 1

function change_role_name() {
    global $wp_roles;

    if ( ! isset( $wp_roles ) )
        $wp_roles = new WP_Roles();

    //You can list all currently available roles like this...
    //$roles = $wp_roles->get_names();

    //You can replace "administrator" with any other role "editor", "author", "contributor" or "subscriber"...
    $wp_roles->roles['administrator']['name'] = 'Owner';
    $wp_roles->role_names['administrator'] = 'Owner';           
add_action('init', 'change_role_name');

Method 2

Actually, there are many ways to achieve that:

With pure php and mysql you can edit the serialized entry in the db. Indeed, WordPress stores the serialized array of roles in wp_options table.


  1. Fetch the serialized array:
    SELECT option_value as serialized_string FROM wp_options WHERE option_name = 'wp_user_roles';
  2. Unserialize the string – php: $rolesArray = unserialize($serialized_string)
  3. Change the role name – php: $rolesArray['role_key']['name'] = "New name"
  4. Serialize back the array – php: echo serialize($rolesArray)
  5. Replace the db option_value content with output from the previous point

If you feel confident with WordPress, you can even use the embedded WordPress REPL in wp-cli to fetch the stored value with get_option('wp_user_roles') and then use update_option to update it.

And (always) remember to backup the db before options manipulation 😉

Otherwise, if you don’t care about role_key value…

…it’s very easy to achieve that with wp-cli:

  1. duplicate the existing role – $ wp role create new_role 'New Role' --clone=old_role
  2. delete the old one – $ wp role delete old_role
  3. then associate new_role to the user(s).
  4. eventually repeat step 1 and 2 until old_role = new_role

Method 3

If you are using WP version 4.7+ you may accomplish this using the wp_roles_init action like so:

add_action( 'wp_roles_init', static function ( WP_Roles $roles ) {
    $roles->roles['administrator']['name'] = 'Owner';
    $roles->role_names['administrator'] = 'Owner';
} );

Method 4

A simple solution would be to just add a user role using add_role, that way you can name it whatever you want and add whatever capabilities you want.

Method 5

You can create a custom localization file. Get this file: and edit using PoEdit tool (for example). In next step save localization file as (or other) and edit wp-config file:

define (“WPLANG”, “en_GB”);

Method 6

You can edit it directly in your DB, and it will be edited permanently for your website. Here is where WP keeps user roles

SELECT * from blog_options WHERE option_name = 'blog_user_roles'

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Comment