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

link|improve this question

75% accept rate
Could you elaborate on what you want to achieve? – BjornW Jul 15 '11 at 15:50
rename user role name, that's it. for example, administrator -> owner – Sean Lee Jul 15 '11 at 17:46
feedback

3 Answers

up vote 5 down vote accepted
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();
    //print_r($roles);

    //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');

http://www.garyc40.com/2010/04/ultimate-guide-to-roles-and-capabilities/

link|improve this answer
feedback

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. http://codex.wordpress.org/Function_Reference/add_role

link|improve this answer
Tried to avoid this, but I guess it's the cleanest way to do without plugin. – Sean Lee Jul 15 '11 at 22:16
feedback

You can create a custom localization file. Get this file: http://svn.automattic.com/wordpress-i18n/pot/trunk/wordpress.pot and edit using PoEdit tool (for example). In next step save localization file as en_GB.mo (or other) and edit wp-config file:

define ("WPLANG", "en_GB");

link|improve this answer
Already tried this method, but some pull down menus were not translated. – Sean Lee Jul 15 '11 at 22:15
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.