X

Cómo cambiar los nombres de usuario predeterminados de WordPress

Snippets by IsItWP

¿Alguna vez has querido cambiar los nombres de usuario predeterminados de WordPress? Este fragmento de código le permitirá cambiar cualquiera de los nombres de rol existentes, como “Administrador”, “Editor”, etc., por el que desee. Esto se mostrará en el menú de selección de roles para los usuarios. Tenga en cuenta que esto no añade un nuevo rol ni cambia permanentemente el nombre.

Instrucciones

Todo lo que tienes que hacer es añadir este código al archivo functions.php de tu tema o en un plugin específico del sitio:

function wps_change_role_name() {
    global $wp_roles;
    if ( ! isset( $wp_roles ) )
        $wp_roles = new WP_Roles();
    $wp_roles->roles['contributor']['name'] = 'Owner';
    $wp_roles->role_names['contributor'] = 'Owner';           
}
add_action('init', 'wps_change_role_name');

Nota: Si es la primera vez que añade fragmentos de código en WordPress, consulte nuestra guía sobre cómo copiar / pegar correctamente fragmentos de código en WordPress, para no romper accidentalmente su sitio.

Si le ha gustado este fragmento de código, por favor considere consultar Cómo crear un formulario de registro de usuario personalizado en WordPress.

Comentarios   Deja una respuesta

  1. Hello,

    How do we revert it? I created a site specific plugin for this, then I deleted it thinking that it was enough to revert back to the default user role label

    1. Hey Cristiano,
      If you’ve created the site-specific plugin manually, then you can go ahead and remove the code snippets you’ve inserted onto your plugin editor page.

      Alternatively, if you’ve installed the Code Snippets plugin, you can deactivate the specific snippet you’ve added by navigating to Snippets » All Snippets from your WordPress dashboard.

      1. Hello,
        Thank you, I deactivated and then removed the plugin but the contributor role, didn’t reverted back. It remains as Owner. Weird, no?

  2. can this be used in multisite wordpress on Version 4.8.2? because i put this code in function.php, its not working on add new user page

  3. How to Change the Default WordPress Role Names to Anything - WPMU DEV enero 4, 2015 en 8:10 am

    […] snippet (thanks to Kevin Chard!) will let you change any of the existing role names. For example, instead of Contributor you could […]

  4. WordPress tip: Modify any role name to fit your needs septiembre 15, 2014 en 7:38 am

    […] to Kevin Chard for the […]

  5. Nice function, but good to keep in mind is that the slug of the Role remains the original…

    1. Yes this is true you would need to also change the slug, however at that point it may be better to create a new role rather than change the name of the existing. I still think this has some uses.

      1. Oh I agree, it definitely has some good uses! I just meant that it is something to keep in mind 🙂

        1. Fair enough, and good point 🙂

Añadir un comentario

Nos alegra que haya decidido dejar un comentario. Tenga en cuenta que todos los comentarios se moderan de acuerdo con nuestra política de privacidad , y que todos los enlaces son nofollow. NO utilice palabras clave en el campo del nombre. Tengamos una conversación personal y significativa.

WordPress Launch Checklist

La lista definitiva para lanzar WordPress

Hemos recopilado todos los elementos esenciales de la lista de comprobación para el lanzamiento de su próximo sitio web de WordPress en un práctico ebook.
Sí, envíeme el ¡gratuito!