For people who are customizing their WordPress backend, sometimes the little things like how to change default role names are needed. This is good for membership sites, multi-author blogs, companies, and more. By default, WordPress has the following roles: Administrator, Contributor, Editor, Author, and Subscriber.
In order to do this, you have to add create a new function for changing WP_Roles. This function will initialize before the headers are fully sent, so you will add_action and use init.
I know the above paragraph was a little heavy to take in, but I linked to the necessary areas so if you’re a new developer to WordPress, you can become more familiar with some of the code and terms used.
Change Default Role Names In WordPress
So, since I went a little into the coding mumbo jumbo, I’ve gone and put together the code for those who just want the goodies. All you do is simply insert the following code into your functions.php file. I recommend adding a little label before the code so you can keep your functions file all nice and easy to find things.
function wp_change_role_name() { global $wp_roles; if ( ! isset( $wp_roles ) ) $wp_roles = new WP_Roles(); $wp_roles->roles['administrator']['name'] = 'Head Honcho'; $wp_roles->role_names['administrator'] = 'Head Honcho'; } add_action('init', 'wp_change_role_name');
Where it says ‘administrator’, replace it with any of the other default roles. Where it says Head Honcho, replace it with what you want to role to be. If you want to change multiple role names, simply copy line 5 and 6, and make the changes you desire. 🙂
Please note that this WordPress trick only changes the name. It doesn’t change the role’s site access level. It also doesn’t add a new role.
Pretty easy and cool, huh? Have fun and don’t be afraid to let me know what you’ve chosen to change default role names on your website to.
Leave a Reply