How to disable the WordPress admin bar

Recently, I’ve received a number of comments and questions regarding the WP admin bar, so I thought it would be best to create a post that will give you some guidance as to how to turn this off for your subscribers. 

I know that some users of the WP-Members™ plugin have asked about adding an option to the plugin to turn it off. For the time being, that is not going to make it onto the project list. The reason for this is that adding additional options/settings requires a significant amount of overhead in terms of programming and also in considering the upgrade process. And for something as simple as the admin bar, which can be managed with 3 lines of code to your functions.php file (or 1 if you really want to be efficient), it’s just not worth it.

So how simple is it?

There is one filter that will turn off the entire admin bar:

add_filter( 'show_admin_bar', '__return_false' );

Adding that single line to your functions.php file (found in your theme folder) will turn off the admin bar for everyone (including you).

Suppose you want to use the admin bar for you (and other admins)?

If you would like to keep the admin bar for yourself, you just need to add a condition to test to see if the current user is an admin.  This example tests if the user has the capability to ‘manage_options’.  (If you have a role manager installed and have made changes to the default WP roles, adjust this accordingly.)

if ( ! current_user_can('manage_options') ) {
	add_filter( 'show_admin_bar', '__return_false' );

This can be used regardless of whether you are using the WP-Members™ plugin or not, but if you are using the plugin, this will prevent your subscribers for having the admin bar appear for them when they are logged in.


  1. James Davis says

    I added this line to the functions.php file, but it the bar remains in place. Is there a place in the file that it needs to be added… at the beginning? at the end? Perhaps that makes a difference?



    • says

      It doesn’t matter whether you put it at the beginning or end, unless you have something else in there that would override it. If you use just the filter, that will shut off the bar for all users. If you use the second example, then it will show for the admin (or, as written, anyone who has ‘manage_options’ capabilities). Be sure you’re not using the second one and looking at it as an admin, because it would still be there for you.

    • says

      Hi Marko – there are already plugins that do that. And if you want to go that direction, a quick google search will turn up some examples, some of which are housed in the plugin repository.

      However, in my opinion, a plugin in this case is overkill when you can accomplish this with 1-3 lines added to your functions file. You don’t need to be a programmer to do that. The above examples are essentially “plug-and-play” when added to your functions.php file (which you would find in your theme’s folder). Just add it to the end of the file – you don’t need anything before or after. However, if your functions.php file ends with a closing php delimiter ?> it needs to go inside of that, not after.

  2. steve grace says

    Hey Chad,
    I’m starting to work with WP-Members and happened across this post. I created my child theme and copied the functions.php file to my child directory and added this code:

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

    worked in Chrome but not FF (both latest versions). Firefox won’t even pull the page – just got blank white. Tested by removing code from functions.php and reloading page and it went back to normal. Any thoughts?
    P.S. using theme called Whitelight from WooThemes

    • Nicole says


      I have a similar issue, if I just add the three lines to functions.php I get a blank page. I’ve tested this in Safari and Firefox.


      • says

        The problem is most likely that you have unicode single quotes which will not work. If you copied what is in Steve’s comment above, that is the problem with that code. Although it may look the same as what is above in the content of this post, it is not. You must use ascii encoded single quotes.

        If you don’t know what that means, just copy the code to notepad, retype the single quotes and you’ll be fine.

    • says

      I’m not sure exactly what you mean by an already opened dialog. The login failed message only occurs if there is a failed login. Other dialogs for the plugin are mostly around the registration process.

  3. giovita says

    I am having two issues. One the admin bar will not show in any browser when i am logged in, two I cannot log out properly. it takes me to a error redirect page.

    can you please help me with this? thank you


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>