Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question
    
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
add comment

3 Answers

up vote 19 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/

share|improve this answer
add comment

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");

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

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

share|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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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