How to change default role names in WordPress

When you start working with WordPress, you will notice there are different user roles you can assign to yourself and others working on the site. There are six different roles (Super Admin, Administrator, Editor, Author, Contributor and Subscriber) which all play a different part on the site.

Although names of the roles can be quite clear to you, not everyone can understand which role gives you which permissions. So you might want to change the names of those roles to something better or even change them to something which will sound more appropriate for your site. Why wouldn’t an Author become a Writing Bro?

Unfortunately, WordPress doesn’t provide an easy way of changing role names so you will have to deal with a tiny code snippet.

  1. Open functions.php file
  2. Copy and paste this code:
  3. function wps_change_role_name() {
    global $wp_roles;
    if ( ! isset( $wp_roles ) )
    $wp_roles = new WP_Roles();
    $wp_roles->roles['author']['name'] = 'Writing Bro';
    $wp_roles->role_names['author'] = 'Writing Bro';
    }
    
    add_action('init', 'wps_change_role_name');
  4. Save changes and enjoy your new role name

As you can see from the code, we have only changed author role name. If you want to change any other role name, simply replace ‘author’ with different role name and ‘Writing Bro’ with anything you want your role to be named.

If you want to change more than one name, simply add these two line of codes and change them as described:

$wp_roles->roles['ROLE_NAME']['name'] = 'NEW_ROLE_NAME';
$wp_roles->role_names['ROLE_NAME'] = 'NEW_ROLE_NAME';

After you have saved changes, you can go to user settings and check your new role name. Enjoy, our Reading Bros.

START YOUR OWN BLOG

This guide is an introduction to mastering the art of blogging. It provides easy to follow steps to start, maintain, and grow your blog.

Read the guide

Leave a Reply

Your email address will not be published. Required fields are marked *