How to disable the WordPress Admin Bar
WordPress 3.1 introduces a new feature called the Admin bar. A lot of people will be wanting to disable this when WordPress 3.1 comes out. Since release candiate 2 you can disable it on a per user basis like this:

But since some people might want to disable the admin bar for everyone, I thought I'd show you a couple of ways to quickly disable the WordPress admin bar, either entirely, or just for you, or just for everyone else.
If you haven't seen it yet, the WP admin bar looks like this, and is added on top of all pages, on both the frontend and backend of your site, when you're logged in:
Disable Admin Bar for everyone
This one is reasonably simple, to disable the WordPress Admin Bar for everyone, add the following to your theme's functions.php file, the first bit hides the admin bar, the second bit hides the settings:
/* Disable the Admin Bar. */
add_filter( 'show_admin_bar', '__return_false' );
<?php function yoast_hide_admin_bar_settings() {
?>
<style type="text/css">
.show-admin-bar {
display: none;
}
</style>
<?php
}
function yoast_disable_admin_bar() {
add_filter( 'show_admin_bar', '__return_false' );
add_action( 'admin_print_scripts-profile.php',
'yoast_hide_admin_bar_settings' );
}
add_action( 'init', 'yoast_disable_admin_bar' , 9 );Disable WordPress Admin Bar for specific requests
You might want to do this for specific requests only, so you can more easily take screenshots, for instance, then you add this to your theme's functions.php file:
if ( isset($_GET['bar']) && 'no' == $_GET['bar'] ) add_filter( 'show_admin_bar', '__return_false' );
This would allow you to disable the WordPress admin bar by going to example.com/?bar=no, you can of course change those values.
Disable WP Admin Bar for specific users
To disable the WP Admin Bar, and the Admin Bar preference on his/her profile page for a specific user, add the following to your theme's functions.php file:
<?php function yoast_hide_admin_bar_settings() {
?>
<style type="text/css">
.show-admin-bar {
display: none;
}
</style>
<?php
}
function yoast_disable_admin_bar() {
if ( 2 == get_current_user_id() ) {
add_filter( 'show_admin_bar', '__return_false' );
add_action( 'admin_print_scripts-profile.php', 'yoast_hide_admin_bar_settings' );
}
}
add_action( 'init', 'yoast_disable_admin_bar' , 9 );Or you could do the reverse, and enable the WordPress Admin Bar just for one user, by disabling it for everyone else:
<?php function yoast_hide_admin_bar_settings() {
?>
<style type="text/css">
.show-admin-bar {
display: none;
}
</style>
<?php
}
function yoast_disable_admin_bar() {
if ( 2 != get_current_user_id() ) {
add_filter( 'show_admin_bar', '__return_false' );
add_action( 'admin_print_scripts-profile.php',
'yoast_hide_admin_bar_settings' );
}
}
add_action( 'init', 'yoast_disable_admin_bar' , 9 );Update 7-1-2011: post updated after some remarks about current_user not being set yet at the point I was calling it, switched to using the proper __return_false helper function too, using the helpful comment from Cor van Noorloos in the comments.
Update 7-1-2011 - 2: post updated after an API change was decided upon and then implemented.

by Caleb on 5 January, 2011 at 01:46
it can be disabled, at least in 3.1rc2. view your profile, and uncheck the "show admin bar."
by Caleb on 5 January, 2011 at 02:00
but definitely useful for killing it all at once or for multiple users
by Joost de Valk on 7 January, 2011 at 13:43
Thanks Caleb, added screenshot of the new interface.
by Caleb on 5 January, 2011 at 02:18
thank you, yoast!
by Swamykant on 5 January, 2011 at 09:35
Hi Joost
I think this similar to wordpress.com. I will check how helpful it for my blog. If not, I will surely use your code.
Thanks alot.
by Cor van Noorloos on 5 January, 2011 at 14:19
Hi Joost,
Not entirely sure what the most recent way to do this is, but removing the admin bar can also be accomplished by
add_filter( 'show_admin_bar', '__return_false' );,And to remove the user setting
remove_action( 'personal_options', '_admin_bar_preferences' );by Joost de Valk on 7 January, 2011 at 13:41
Thanks Cor, used your input in my update of the post above :)
Pingback: WordPress tip: Remove WP 3.1 Admin Bar
by Krystian on 5 January, 2011 at 17:35
Hi Joost,
AFAIK 3.1. is not released yet, so modification you prosose c an fail to work with the released version. Also option to enable/disable admin bar can be introduced later.
by Joost de Valk on 5 January, 2011 at 17:40
I know, and you know what? This is a content management system, if needed, I can just update the post ;)
by Bob Dunn on 5 January, 2011 at 18:02
Quick question, if you make this change to your theme's fuctions.php file, and your theme doesn't have a custom.funtions.php file, then if you upgrade your theme it will get overwritten, right?
by Joost de Valk on 5 January, 2011 at 18:04
Yes.
by Zen on 5 January, 2011 at 19:08
Wouldn't a child theme prevent this?
by Simon on 6 January, 2011 at 08:32
Not sure why, but I've never seen that admin bar in my admin panel. I've actually WANTED to see it. Anyone know a reversey-ma-hoo to get the admin bar up there?
by Joost de Valk on 6 January, 2011 at 08:41
It's in WP 3.1 :)
by Simon on 6 January, 2011 at 08:52
Bah! Just realized I didn't have it. Thanks :D
by Stijn on 6 January, 2011 at 16:53
Funny. I've been adding the WordPress Admin Bar by using the plugin with the same name. I find that it makes things much easier to work. It doesn't look like the example in your screenshot though. I will have to give it a try and see if it's better; if not, then I'll surely come back and use this hack to hide it.
by Mike Devarenne on 6 January, 2011 at 17:07
What would be useful is to disable WP admin bar for user roles.
Thanks for your many tips Joost!
by Dummy00001 on 7 January, 2011 at 02:32
I have a WP account now and on bunch of sites the admin bar started showing up.
What are my option as an user?
Or annoying blog owners to disable it is the only option?
by Theo on 7 January, 2011 at 17:00
Great snippet, thank you Joost!
by Rami on 9 January, 2011 at 01:51
What about
remove_action( 'init', 'wp_admin_bar_init' );?
by Ryan on 11 January, 2011 at 12:34
When I tried that with WP 3.1 RC2, it got rid of the admin bar, but didn't remove the gap inserted at the top of the page.
This admin bar is stupid IMO. It seems to replace the existing menu in the WP admin panel, yet the original one is still there. IMO, WordPress should either use the admin bar only, or just use the standard menu in the left hand side. This combination approach is just weird and I don't like it one little bit.
Maybe it will grow on me in time.
by James McWhorter on 9 January, 2011 at 06:39
Good stuff, Joost. Bookmarked for future use.
by GaryJ on 9 January, 2011 at 06:48
Since changeset 17234, the second part of your first code snippet won't work. The user preferences will still be visible, unless you use CSS. Time to update the article again :-)
by Cor van Noorloos on 10 January, 2011 at 21:32
Hi Gary,
I'm afraid your right. CSS would do the trick, but somehow I prefer the jQuery way of doing this.
function cor_personal_options() {?>
jQuery(document).ready( function() {
jQuery( "form#your-profile table.form-table tr.show-admin-bar" ).remove();
} );
<?php
}
add_action( 'personal_options', 'cor_personal_options' );
Pingback: How to disable the WordPress admin bar | 24design
Pingback: How to Remove the Admin Bar in WordPress