Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
Copa WPB
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

Cómo desactivar la barra de administración de WordPress para todos los usuarios excepto los administradores

Algunos lectores nos han preguntado cómo desactivar la barra de administrador / administración de WordPress. Aunque se trata de un pequeño retoque, algunos usuarios prefieren hacerlo por varias razones, como mantener una interfaz de usuario más limpia o mejorar la experiencia de usuario para los usuarios que no son administradores.

Por defecto, puede desactivar fácilmente la barra de administración de WordPress para usuarios individuales. Sin embargo, esto puede llevar mucho tiempo si tienes un gran número de usuarios registrados en tu sitio.

En este artículo, le mostraremos cómo desactivar fácilmente la barra de administrador de WordPress para todos los usuarios excepto los administradores.

How to disable WordPress Admin Bar for All Users except administrators

¿Qué es la barra de administrador de WordPress?

Por defecto, WordPress muestra una barra de administrador en la parte superior de la pantalla para todos los usuarios conectados. Cuando acceda a su cuenta, podrá ver esta barra en el área de administrador de WordPress y en el resto de páginas.

The WordPress admin bar

La barra de herramientas de administración de WordPress tiene atajos útiles a diferentes áreas del backend de WordPress, y estos atajos cambian según el perfil y los permisos del usuario en WordPress.

Sin embargo, la barra de administrador puede distraerle cuando está mirando la parte frontal de su sitio web.

También puede afectar al diseño de su sitio web y a la experiencia del usuario. Esto puede ser un problema si está creando o gestionando un sitio WordPress para terceros, ya que les impide ver el aspecto real de su sitio web.

Por suerte, hay varias formas de desactivar la barra de administrador para todos los usuarios excepto los administradores. Simplemente usa los enlaces rápidos de abajo para saltar al método que quieras usar:

Tutorial en vídeo

Subscribe to WPBeginner

Si prefiere instrucciones escritas, siga leyendo.

Método 1: Cambiar los permisos de cada usuario en WordPress

Puedes desactivar la barra de administrador para usuarios específicos simplemente editando su perfil de usuario. Este es un método rápido y fácil si sólo necesita eliminar la barra para un pequeño número de personas. Sin embargo, si tienes un sitio de membresía con muchos usuarios, te recomendamos que elijas otro método.

Para eliminar la barra de administración manualmente, simplemente vaya a la página Usuarios ” Todos los usuarios en el escritorio de administración de WordPress. A continuación, pase el cursor sobre el usuario de WordPress que no necesita la barra de administración y haga clic en “Editar” cuando aparezca.

How to edit a user's profile in WordPress

Se abrirá el perfil de ese usuario.

Desde aquí, desmarque la casilla siguiente a la opción “Mostrar barra de herramientas al ver el sitio”.

How to hide the admin toolbar for non-admin users

A continuación, desplácese hasta la parte inferior de la pantalla y haga clic en “Actualizar usuario” para guardar los cambios. Esto desactivará la barra de administrador solo para esa persona específica.

Para ocultar la barra de herramientas a más usuarios, sólo tiene que seguir el mismo proceso descrito anteriormente.

Método 2: Utilizar un código para desactivar la barra de administración para usuarios no administradores (recomendado)

Si necesitas ocultar la barra de administrador para muchas personas, cambiar manualmente los ajustes de cada usuario te llevará mucho tiempo y esfuerzo.

Por ello, recomendamos desactivar la barra de administración añadiendo código al archivo functions.php, que es un archivo de tema de WordPress.

Algunas guías le dirán que edite los archivos del tema manualmente, pero esto puede causar errores comunes de WordPress e incluso puede romper completamente su sitio web.

Por esa razón, recomendamos usar WPCode. Es el mejor plugin de fragmentos de código y facilita añadir código personalizado en WordPress sin poner en riesgo su sitio.

Hemos utilizado WPCode para cambiar la combinación de colores del administrador / administración, quitar el texto ‘Hola Admin’, desactivar el botón de opciones de pantalla, y mucho más.

En primer lugar, deberá instalar y activar el plugin gratuito WPCode. Para más información, consulte nuestra guía práctica sobre cómo instalar un plugin de WordPress paso a paso.

Una vez activado el plugin, vaya a Fragmentos de código ” Añadir fragmento.

Hiding the admin toolbar using WPCode

Aquí verá todos los fragmentos de código prefabricados que puede añadir a su sitio.

De hecho, WPCode tiene el fragmento de código exacto que necesita para desactivar la barra de administración en su biblioteca de fragmentos incorporada. Simplemente vaya a Fragmentos de código Biblioteca.

The WPCode code snippet plugin for WordPress

Aquí, busque ‘Desactivar la barra de administrador de WP’.

Cuando aparezca el fragmento de código adecuado, haz clic en su botón “Usar fragmento”.

The ready-made Disable The WP Admin Bar code snippet

El plugin añadirá automáticamente el código a su sitio, le dará un título descriptivo, elegirá el método de inserción correcto e incluso añadirá etiquetas para ayudarle a identificar el fragmento.

Este es el aspecto del código:

/* Disable WordPress Admin Bar for all users */
add_filter( 'show_admin_bar', '__return_false' );

Ahora, si su objetivo es desactivar la barra de administrador para todos los usuarios, entonces todo lo que necesita hacer es conmutar el interruptor de ‘Inactivo’ a ‘Activo’ y luego hacer clic en ‘Actualizar’.

Adding custom code to WordPress

Sin embargo, como nuestro objetivo es desactivar la barra de administración de WordPress para los usuarios que no son administradores, tenemos que hacer algunos pequeños retoques en el código.

Puede sustituir el código existente por el siguiente:

/* Disable WordPress Admin Bar for all users except administrators */
add_filter( 'show_admin_bar', 'restrict_admin_bar' );

function restrict_admin_bar( $show ) {
    return current_user_can( 'administrator' ) ? true : false;
}

Este código identifica a los usuarios que no son administradores y que no están viendo el panel de administración. Para estos usuarios, desactiva la barra de administrador de WordPress.

Después, desplácese por la página hasta la sección ‘Inserción’. Aquí, puedes mantener el método por defecto de ‘Auto Inserción’ para asegurarte de que el código se ejecuta en todas partes.

Automatically inserting code into a WordPress website

Por último, desplácese a la parte superior de la pantalla y haga clic en el carrusel / control deslizante “Inactivo” para que aparezca “Activo”.

A continuación, basta con hacer clic en el botón “Guardar fragmento” o “Actualizar” para que el fragmento de código pase a estar activo.

Publishing a code snippet to disable the WordPress admin bar for non-admin users

Ya está. Sólo recuerde marcar / comprobar su sitio web de WordPress para asegurarse de que todo funciona bien.

Método 3: Utilice un plugin gratuito para desactivar la barra de administración para usuarios no administradores.

Si no quieres añadir código a tu sitio web, entonces puedes ocultar la barra de administrador usando un plugin. Hide Admin Bar Based on User Roles le permite quitar la barra de herramientas en función de los diferentes perfiles de usuario, por lo que esta es una buena opción si desea desactivar la barra para todos los miembros, clientes de WooCommerce, o algún otro perfil de usuario.

En primer lugar, debes instalar y activar el plugin Ocultar la barra de administrador en función de los perfiles de usuario. Para más detalles, consulta nuestra guía paso a paso sobre cómo instalar un plugin de WordPress.

Una vez activada, debe ir a la página Ajustes ” Ocultar barra de administrador. A continuación, marque / compruebe las casillas situadas junto a los perfiles de usuario en los que desea desactivar la barra de administrador.

Hiding the admin toolbar for specific user roles

Una vez hecho esto, basta con hacer clic en “Guardar cambios” para establecer los ajustes.

Esperamos que este artículo te haya ayudado a aprender cómo desactivar la barra de administración de WordPress para todos los usuarios excepto los administradores. Puede que también quieras ver nuestra guía sobre cómo recibir avisos por correo electrónico de los cambios en las entradas de WordPress y nuestra selección de los mejores plugins de seguimiento y registro de actividad de WordPress.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Descargo: Nuestro contenido está apoyado por los lectores. Esto significa que si hace clic en algunos de nuestros enlaces, podemos ganar una comisión. Vea cómo se financia WPBeginner , por qué es importante, y cómo puede apoyarnos. Aquí está nuestro proceso editorial .

Avatar

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

El último kit de herramientas de WordPress

Obtenga acceso GRATUITO a nuestro kit de herramientas - una colección de productos y recursos relacionados con WordPress que todo profesional debería tener!

Reader Interactions

161 comentariosDeja una respuesta

  1. Hussam H

    Thank you and bless you.

    • WPBeginner Support

      You’re welcome!

      Administrador

  2. Paul

    Using the after_setup_theme hook doesn’t always work. Try this instead:

    function remove_admin_bar( $value ) {
    return ( current_user_can( ‘administrator’ ) ) ? $value : false;
    }
    add_filter( ‘show_admin_bar’ , ‘remove_admin_bar’);

  3. Matthew D Henderson

    Thank you for providing four different ways to do this. Perfect

    • WPBeginner Support

      Glad you found our recommendations helpful :)

      Administrador

  4. Joey

    What would be the code if I want to add Editor and Admin to show the Admin bar..

    if (!current_user_can(‘administrator’) && !is_admin())…

    if (!current_user_can(‘editor’) && !is_editor())…

    would it be if (!current_user_can(‘administrator’) && !is_admin() || !current_user_can(‘editor’) && !is_editor())

    would this work?

    • WPBeginner Support

      For what you are wanting, you would want to remove: && !is_editor()

      Then it should work how you are wanting.

      Administrador

  5. Basia

    Hi,
    I hide admin bar with plugin You recommend, but when subscriber log in he can still click on “view my profile” and see wp dashboard. Can I disable that?

  6. Deewinc

    Thanks for the article but method 3 doesn’t work.

    • WPBeginner Support

      If method 3 is not working for you, we would recommend trying one of the other methods to test.

      Administrador

  7. Dipesh Vedak

    what if theme upgrades?

    • WPBeginner Support

      If you created a site-specific plugin it would remain.

      Administrador

  8. Brandon Porter

    Worked like a charm. Thank you!

    • WPBeginner Support

      You’re welcome, glad our guide was helpful :)

      Administrador

  9. Bryan E Jackson

    Doesn’t seem to work for my Divi Theme :(

    • WPBeginner Support

      You may want to try clearing your cache for the most common reason for the change not being visible.

      Administrador

  10. Paul

    What exactly does this disable? I still see an admin bar and I have access to menu options when I go to example.com/wp-admin when i’m logged into a subscriber account.

    • WPBeginner Support

      You would want to ensure the code was properly added for the most likely cause of the admin bar not being hidden otherwise, you could also have a plugin that would be overriding this code.

      Administrador

  11. Jürgen

    Thanks. Just what I needed

    • WPBeginner Support

      Glad our guide was helpful :)

      Administrador

  12. khaoula

    Thanks a lot ,but what to do if the user wants to logout ?

  13. Kaetech

    Thanks a lot. Just what I needed. It worked.

    • WPBeginner Support

      You’re welcome, glad our guide was helpful :)

      Administrador

  14. Marc Korden

    Cannot add the admin code in my theme:

    Communication with the site not possible to check for errors, the PHP adjustment has been reversed. The PHP file change needs to be changed in another way, for example using SFTP.

  15. Jailson Pacagnan Santana

    Thanks! God bless you

    • WPBeginner Support

      You’re welcome, glad our guide was helpful :)

      Administrador

  16. Ciao

    Where should i exactly insert the code, at the beginning, at the end of funcions.php? thx

    • WPBeginner Support

      We normally recommend at the end so it is easy to find and remove if needed

      Administrador

  17. Agha Mubasher

    Hello there…!
    First of all i simply love the work wpbeginner, as you always bring forward the simplest solutions to our wordpress issues. Your website and Youtube channel has always been helpful for me. Thumbs Up for that.. :)

    I had issue with hiding the admin bar for the subscribers only. Now after applying your code in the function.php it is hidden for my editors also.
    Is there any way that my editors also can see the admin bar and only it should be hidden from the subscribers..!!

    • WPBeginner Support

      For that, you would need to target another permission that your editor has instead of what we are targeting such as edit_others_posts

      Administrador

    • WPBeginner Support

      You’re welcome :)

      Administrador

  18. Dana Jewel

    Thank you! This snippet has been really, really helpful.

    • WPBeginner Support

      You’re welcome, glad our guide could be helpful :)

      Administrador

  19. Faris

    Great Help, It worked like a charm!
    Thank You so much.

    • WPBeginner Support

      You’re welcome :)

      Administrador

  20. Jesaja

    On my website it says:

    “Unable to communicate back with site to check for fatal errors, so the PHP change was reverted. You will need to upload your PHP file change by some other means, such as by using SFTP.”

    What to do now?

  21. TaiRon

    It does work like a chame, your code is perfect but I have to change in file manager directly.

    Thanks.

    • WPBeginner Support

      You’re welcome, glad our guide could help :)

      Administrador

  22. Bongani

    Thanks , very useful tutorial

    • WPBeginner Support

      You’re welcome :)

      Administrador

    • WPBeginner Support

      You’re welcome :)

      Administrador

  23. Jim

    Can this code be altered to allow the WordPress Admin bar for Admins AND moderators, but hide it for everyone else?

    Thanks!

  24. Andreas

    If a user knows the URL structure of WordPress he can easily browser to /wp-admin/ and there the admin toolbar will be visible. Also, the easiest way is to deactivate it in the user setting if you have a small number of users.

  25. Adam Pressman

    Doesn’t work. Well, to be fair, works when you first use it but then something happens and it doesn’t anymore. nothing is overwriting the functions.php and the code is there but usually after the first login, logout cycle a subsequent login will see the admin bar return.

  26. prashanth

    It works but user cannot logout. How to logout?

  27. Cesar

    I have created a social media site using several plugins and everything works fine but for one issue. Pages are successfully restricted and redirected (Buddypress pages, blogs, etc) for non-logged in users.

    However the main issue I am having is that non-logged in users can still have access to blog posts and user profile pages via widgets placed on side bar and footer and I cannot seem to find a solution anywhere.

    Any ideas on the matter, plugins or code that I can insert in the child theme?

    I have been looking for a solution for over a day and all there is there is how to restrict pages and partial content but nothing works on the widget links, they keep going thru the restrictions in place.

    Thanks

    • WPBeginner Support

      Hey Cesar,

      There are several widgets and plugins that allow you to hide widgets from non-logged in users. However, if non-logged in users know the URL, then they would still be able to access those URLs directly. You need to review your plugin settings and see if you can find the option to hide profile pages from non-logged in users.

      Administrador

  28. Shabz

    This code or several others that I tried from the comments isn’t working. I’m trying to remove that dumb silver/black wordpress tab above my menu that shows up for all of my website’s users. How do I remove that? Please help :)

  29. Humberto Buitrago

    Is there any plugin we can use instead code?

    Thanks in advanced!

    • Jack Hernandez

      As mentioned in the article, you included a way for users to edit their profiles through the front end without the admin bar. How did you accomplish that.
      Thanks

  30. Paritosh Negi

    Thank you so much! <3 it works well

  31. Chouchouda

    Hello, some issue , i have done everything but can’t hide toolbar for owner user in frontend , but can do this for admin user , incredible.
    I’m using search& go theme wordpress , Thank for your help.

  32. Alex

    Hello,

    Code needs a little updating. This is the code I would use to redirect by role.

    /*Hide admin bar for certain roles*/
    function hide_admin_bar() {
    if(is_user_logged_in() ) {
    $current_user = wp_get_current_user();
    if ( in_array( ‘subscriber’, (array) $current_user->roles ) ) {
    add_filter(‘show_admin_bar’, ‘__return_false’);
    }
    }
    }

    Hope this helps.

    • Brandon

      Thanks for this updated code, Alex. Simple and works great.

      Put it in child theme functions.php and forget about it. :)

    • Yuki Zain

      Thanks, Alex but I’m editing a bit

      /*Hide admin bar for certain roles*/
      if(is_user_logged_in() ) {
      $current_user = wp_get_current_user();
      if ( in_array( ‘subscriber’, (array) $current_user->roles ) ) {
      add_filter(‘show_admin_bar’, ‘__return_false’);
      }
      }

    • randalf

      Very nice :) but what do I do if I have two roles as a result of bbpress plugin.. That is registered users have the subscriber role in whole site and participant role in bbpress.
      Please help

  33. Scott

    Hi,

    I inserted your code to remove the Admin bar from my membership site. Unfortunately it also removed it from me, the Admin (even thought I used your first option above). I am using the Tesseract Pro theme. Do you have any suggestions? Thanks

  34. Inder Singh

    Dear Sir,
    I have 2 admin user and i want to show admin bar for first user and remove admin bar for second user in wordpress.
    How can i do it.

    Thanks for support.

  35. SG

    I tried using this and I got that code Parse error: syntax error, unexpected ‘}’ in /home/content/76/10323476/html/wp-content/themes/digitalscience-apex/functions.php on line 168 and I can’t get my site back even after deleting it.

  36. Krzysiek Dróżdż

    Well, I wouldn’t use current_user_can for that… Codex says, that you can use it for role checking, but in the code you can find:

    * While checking against particular roles in place of a capability is supported
    * in part, this practice is discouraged as it may produce unreliable results.

    So… Much better and secure way to do this is:

    $user = wp_get_current_user();
    if ( ! in_array( ‘administrator’, (array) $user->roles ) ) {

    }

  37. Rajdeep dey

    This code not working on my website… Did any one have any other solutions for hiding admin bar.

  38. Lyndal Sirit

    i used it and it crashed my site, trying desperately to fix it now, i took the code back out and updated but I am getting an Error: Parse error: syntax error, unexpected ‘3’ (T_LNUMBER) in /home/lyndalspirit/public_html/wp-content/themes/primer/functions.php on line 516

    • WPBeginner Support

      Hi Lyndal,

      Some times when users copy code from websites like WPBeginner, they also copy the line numbers which they are not supposed to copy. When they paste this code in their functions.php file it causes an error.

      You need to connect to your site using an FTP client. Locate your functions.php go to the code you added and remove it. Save your changes.

      Administrador

      • SG

        Even after deleting it, my site is coming back HELP!

  39. Chris

    This worked fine for me as-is, i stripped out the line numbers and stuck it at the end of my theme functions.php – instant success. thanks so much.

  40. Job

    The Code works like charm. Thanks.

  41. eli

    if(!current_user_can(‘administrator’)) {
    add_filter(‘show_admin_bar’, ‘__return_false’);
    }

  42. Gordon Cockburn

    How do I remove an individual ex member from access to members only area of website

    • WPBeginner Support

      Login to your WordPress admin area using an Administrator account. Click on the Users menu item from the admin sidebar. This will show you a list of users registered on your WordPress site. Locate the user you wish to remove. Click on the Delete link below the username of the person you want to remove.

      Administrador

  43. Jguiss

    Didn’t worked for me…
    It’s worked with that : add_filter(‘show_admin_bar’, ‘__return_false’);

    • JGUISS

      JGUISS

      Didn’t worked for me…
      It’s worked with that : add_filter(‘show_admin_bar’, ‘__return_false’);

      how does the code look like with this added I’m not familiar enough with php to add it in

  44. The Little Binger

    Hello!

    Thank you so much for being such a great help! I installed this code on the function file but it does not seem to work. I loaded my page on a different browser but the Log In bar is still there. Why is that? I also read your article about adding codes to the PHP file.

    I hope you could help me out on this. Thanks!!

  45. Vic

    Hi! First of all, thanks for these codes, it’s very helpful, provided I considered myself not a first timer anymore who remember to add after the codes!
    I locked myself at the first time trying to add the php coding in my functions.php file as well, thanks to the “expert” web developer who didn’t show the full set of codes for a function. And thanks to your “what to do when you are locked out of WordPress admin area” site, I found out why I was locked out in the first place! But it took me a downtime of 3 days to figure out how to use the FTP, which at the end failed to function, but my webhost Helpdesk suggested me to use the File Manager in their Control Panel instead! Luckily it works! Lessons learnt the hard way, but worth it.. :P
    Just a kind suggestion, since this site was supposed meant for “WPBeginner”, I think all of the WP users beginner would appreciate if full set of codes are provided, rather than every other person “shouting” in the comment section that “The codes didn’t work, and locked me out”, and then you have to advise them to read a full length of another tutorial how to unlock their website, even though yes, you wish to teach us “How to fish” instead of “Fish for us” every time!
    Anyway, thanks again and appreciate your efforts here in guiding us, the WP Beginners! :)

    • WPBeginner Support

      Thanks for the feedback. We try to make code easy to paste and use. However, usually there is already code in your functions.php file, which may affect the end result. We are glad you found your way out. :)

      Administrador

  46. Louis

    It works just perfect!
    Easy and functional.
    Thank u!

  47. lucas

    Yo your code line has ruined both of my sites I cannot acces the wp-admin at all I get a fatal error message.. how can I fix this please :(

  48. Peters A P

    I did what was mentioned on the link you send me.

    Now the entire site is gone

    I cannot see anything, please check for yourself and see.

Deja tu comentario

Gracias por elegir dejar un comentario. Tenga en cuenta que todos los comentarios son moderados de acuerdo con nuestros política de comentarios, y su dirección de correo electrónico NO será publicada. Por favor, NO utilice palabras clave en el campo de nombre. Tengamos una conversación personal y significativa.