Blog

WEBFI-WordPress-How to Disable WordPress Admin Bar for All Users Except Administrators



Some sites want to hide the ability for logged in users to see the admin bar. This is to hide it from users who will not be using the bar. In this video, we will show you how to disable the WordPress admin bar for all users except administrators.

If you liked this video, then please Like and consider subscribing to our channel for more WordPress videos.

Text version of this tutorial:
http://www.wpbeginner.com/wp-tutorials/how-to-disable-wordpress-admin-bar-for-all-users-except-administrators/

Follow us on Twitter:
http://twitter.com/wpbeginner

Checkout our website for more WordPress Tutorials
http://www.wpbeginner.com/

Summary of this Tutorial:

Start by going to your theme area in administrator

Click Editor and find your functions.php and paste the code in

add_action(‘after_setup_theme’, ‘remove_admin_bar’);

function remove_admin_bar() {
if (!current_user_can(‘administrator’) && !is_admin()) {
show_admin_bar(false);
}
}

source

21 Comments

  • Lynn Monahan on September 8, 2014

    as a "true" beginner I don't even know what the admin bar is.  Maybe you could add that in your instructions.  Show us first where the admin bar is and what it is.

  • Alex Holzmann on September 24, 2014

    perfect, thank you!

  • deshetti on October 23, 2014

    I was trying to do what what mentioned in this video and it did not work. I used the following instead which did the trick from me: 

    if ( ! current_user_can( 'manage_options' ) ) {
        show_admin_bar( false );
    }

    The above was mentioned in the wordpress codex: http://codex.wordpress.org/Function_Reference/show_admin_bar

  • SinLikeFlynn on March 25, 2015

    Worked a charm, thanks a mill!!!

  • steven thompson on April 12, 2015

    I tried this recommendation and it took my site down be careful

  • JozefN on September 23, 2015

    If you copy paste the code, make sure you don't copy the line indicators along with it, as it will make your site non functional.

  • Laura Norese on October 29, 2015

    Thanks, it's works! In few seconds I've removed the admin bar for all users except Administrator.

  • Raven9547 on December 3, 2015

    Dont copy and paste it…..you need to change the "9" with an '
    False ('administrator9;)
    Right ('administrator';)

  • Ottawa_Slumlord on December 8, 2015

    Word of advice: GO SLOWER. I could barely follow what you were doing as you were going so quickly.

  • Thomas Golaszewski on December 10, 2015

    you are so fast, too fast

  • WeActOnImpulse Official on February 29, 2016

    word of advice: don't put jumpcuts in a tutorial dealing with code.

  • WeActOnImpulse Official on March 1, 2016

    also the admin bar is still there for logged out users

  • walter harris on March 15, 2016

    What the hell was that…. blast through on high speed forward with no explanations
    Waste of time…

  • Aamer Shahzad on April 21, 2016

    Hi, this is fine may be its working or not, but the right way to do this is to use the add_filter() function. see the below code.

    /* =============== code ============== */
    add_filter( 'show_admin_bar', '__return_false' );

    or you can disable for other users but not for yourself (administrator)

    /* =============== code ============== */
    if ( !current_user_can('administrator') ) {
    add_filter('show_admin_bar', '__return_false');
    }

    place the code in your theme's functions.php

  • SuperHuman Wave on May 1, 2016

    yo what the ffff was that?? I entered this shitty code and now I have a blank page, both my websites are gone and I was just editing 1?? is this a fucking joke? how can I fix this!!

  • Charles Mackatoni on November 1, 2018

    Had to watch this a few times.
    Was stoked when it happened.
    Patience.. #276er

  • Jonathan Granados on April 13, 2019

    thanks so much GOD BLESS YOU, is working fine

  • Friday Shegun on January 17, 2020

    It works Perfectly Thanks a bunch

  • tayyab siddique on May 4, 2020

    dint work for me

  • DSPplug on January 22, 2021

    Thanks, perfect

  • JukeSkillz on January 27, 2021

    Mine says editor locked ??????? What

WhatsApp us
Live Chat

Office hours operation Mon-Sun 8:00 am ET – 4:00 pm ET

To start your Premium WP or Cpanel service, use our domain search engine, if the domain you want is available, contact us by Whats app to activate your project.

The easiest, fastest, and most secure way to communicate with us.
loading
Please enter your domain.
Please verify that you are not a robot.

Terms Privacy

 

 

error: WEBFINET SECURITY IS ON