Some readers have asked us how to disable the WordPress admin bar. While it’s a small tweak, some users prefer to do this for various reasons, such as maintaining a cleaner user interface or enhancing the user experience for non-admin users.
By default, you can easily disable the WordPress admin bar for individual users. However, this can be time-consuming if you have a large number of registered users on your site.
In this article, we will show you how to easily disable the WordPress admin bar for all users except administrators.
What Is the WordPress Admin Bar?
By default, WordPress shows an admin bar at the top of the screen for all logged-in users. When you are logged into your account, you can see this toolbar in the WordPress admin area and all other pages.
The WordPress admin toolbar has useful shortcuts to different backend areas of WordPress, and these shortcuts change based on a user’s role and permissions in WordPress.
However, the admin bar can be distracting when you are looking at the front end of your website.
It may also affect your website’s design and user experience. This can be a problem if you are building or managing a WordPress site for a third party, as it stops them from seeing what their website really looks like.
Luckily, there are multiple ways to disable the admin bar for all users except administrators. Simply use the quick links below to jump to the method you want to use:
Video Tutorial
If you prefer written instructions, then just keep reading.
Method 1: Change Each User’s Permissions in WordPress
You can disable the admin bar for specific users by simply editing their user profile. This is a quick and easy method if you just need to remove the bar for a small number of people. However, if you run a membership site with a lot of users, then we recommend choosing a different method.
To remove the admin bar manually, simply go to the Users » All Users page in the WordPress admin dashboard. Then hover your mouse over the WordPress user who doesn’t need the admin bar, and click on ‘Edit’ when it appears.
This will bring open that user’s profile.
From here, uncheck the box next to the ‘Show toolbar when viewing site’ option.
After that, scroll to the bottom of the screen and click on ‘Update User’ to save your changes. This will disable the admin bar for that specific person only.
To hide the toolbar for more users, simply follow the same process described above.
Method 2: Use Code to Disable Admin Bar for Non-Admin Users (Recommended)
If you need to hide the admin bar for lots of different people, then changing each user’s settings manually would take a lot of time and effort.
For that reason, we recommend disabling the admin bar by adding code to the functions.php file, which is a WordPress theme file.
Some guides will tell you to edit the theme files manually, but this can cause common WordPress errors and may even completely break your website.
For that reason, we recommend using WPCode. It is the best code snippet plugin and makes it easy to add custom code in WordPress without putting your site at risk.
We’ve used WPCode to change the admin color scheme, remove the ‘Howdy Admin’ text, disable the Screen Options button, and more.
First, you will need to install and activate the free WPCode plugin. For more information, see our step-by-step guide on how to install a WordPress plugin.
Once the plugin is activated, go to Code Snippets » Add Snippet.
Here, you will see all the pre-made snippets you can add to your site.
In fact, WPCode has the exact code snippet you need to disable the admin bar in its built-in Snippet Library. Simply go to Code Snippets » Library.
Here, search for ‘Disable The WP Admin Bar’.
When the right snippet shows up, just click on its ‘Use Snippet’ button.
The plugin will automatically add the code to your site, give the code a descriptive title, choose the correct insertion method, and even add tags to help you identify the snippet.
Here’s what the code looks like:
/* Disable WordPress Admin Bar for all users */
add_filter( 'show_admin_bar', '__return_false' );
Now, if your goal is to disable the admin bar for all users, then all you need to do is toggle the switch from ‘Inactive’ to ‘Active’ and then click on ‘Update’.
However, since our goal is to disable the WordPress admin bar for non-admin users, then we need to make some small tweaks to the code.
You can replace the existing code with the following:
/* 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;
}
This code identifies any non-admin users who are not currently looking at the admin dashboard. For these users, it disables the WordPress admin bar.
After that, scroll down the page to the ‘Insertion’ section. Here, you can keep the default’ Auto Insert’ method to make sure the code runs everywhere.
Finally, scroll to the top of the screen and click on the ‘Inactive’ slider so that it shows ‘Active.’
Then, just click the ‘Save Snippet’ or ‘Update’ button to make the code snippet live.
That’s it! Just remember to check your WordPress website to make sure everything is working fine.
Method 3: Use a Free Plugin to Disable Admin Bar for Non-Admin Users
If you don’t want to add code to your website, then you can hide the admin bar using a plugin. Hide Admin Bar Based on User Roles lets you remove the toolbar based on different user roles, so this is a good choice if you want to disable the bar for all members, WooCommerce customers, or some other user role.
First, you need to install and activate the Hide Admin Bar Based on User Roles plugin. For more details, see our step-by-step guide on how to install a WordPress plugin.
Upon activation, you need to go to the Settings » Hide Admin Bar Settings page. From here, check the boxes next to the user roles where you want to disable the admin bar.
With that done, simply click on ‘Save Changes’ to store your settings.
We hope this article helped you learn how to disable the WordPress admin bar for all users except administrators. You may also want to see our guide on how to get email notifications for post changes in WordPress and our expert picks of the best WordPress activity log and tracking plugins.
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.
Destiny Boy
This was very simple ans straight forward, it helped me
ronald osoo
This code has bug , its working but not bullet proof . The normal user can by -pass this and get access to the user admin like panel at the top by just adding wp-admin/ to the url like trying to login
Math
I agree, direct access to wp-admin/profile.php is making this useless.
Steve
A lot of websites not only from wordpress have the same option. You can acces to the admin-login page of any website just writing example.com/admin : Thats normal. I find it’s look really good without the adminbar.
Alex S
Hello,
I wish your syntax highlighter was better. Tried to copy the code and got the numbers starting at 2. I don’t need your numbers, just the good code. I would use this site a lot more if this was not the case.
Thanks.
WPBeginner Support
You can also click on the little button on top right corner of the code snippet. It will open the raw code in a popup, which is much easier to copy.
Admin
stefano
It works well, but the bar remains for visitors, who have not made the LOGIN
Jenn
This plugin was working great and I was using Theme My Login. When I deactivated that plugin it is not not functioning as before… I see the admin bar for all users. Any suggestions?
Jenn
Sorry I meant to say this ‘code’ was working great. I created a site-specific plugin as well and everything was working great. But after deactivating Theme My Login, not it seems to not have any effect and I see the admin bar on all users.
Suggestions?
Jenn
I just tried adding in the code for all users: show_admin_bar(false); and I can still see the admin bar.
Alexander Pardo
Thank you very much ! A very simple and clean solution.
Jason A. Churchill
I’m not well-read in editing the functions.php file. My first two attempts resulted in syntax error messages.
Where exactly should I place this code in the functions.php file?
WPBeginner Support
At the end. If your functions.php file ends with ?> then you need to paste the code just before it.
Admin
Terry Hale
Thanks so much for this! No plugins, nice, clean, simple.
WPBeginner Staff
WordPress admin bar is displayed only for logged in users.
Bhris
Great straight-to-the-point tutorial.
Is there a version of the code that will block all non-users. That is, visitors to the site won’t see the bar, while all logged-in users would?
Shashi
I was trying to do what what was mentioned in the article 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
vipin
Thanks a lot its really cool…………
Karen
Neither worked for me. I copied the numbers with the text as I did not know that I could
click on the button on top right corner of the code snippet and copy the raw code. I removed the numbers, but overlooked the seven. I had to change the file entry in via my file manager as I could no longer edit the functions.php. So after a scare and a bit of back and forth I removed the number and the admin bar is still there. I also tried your code Shashi, but it’s not working either.
I have tried every plugin under the sun and nothing will remove the bar.
kim04099
Thank You!!
Che Boielle
Fastest fix to an odd issue I’ve ever found and implemented. Great explanation simple to follow instructions. Thanks guys, will be book marking your site.
Manthan
Thanks, Its the easiest way found..!!!
Ryan McGovern
Thanks for the code snippet!
Anup
Why not simply do this for any specific user.
Jack
It would be hard to do this if you have many users.
Róger Marroni
Great job man!
thank you very much!
Mega
I tried and my site is black.
Ryan S
the first step works fine, it is something in your end, maybe while implementing the code
Etienne
Perfect piece of code… Thanks a lot!
Cheers
Nathan Jansen
Use this if you want this only for a certain role
function remove_admin_bar() {
$user = wp_get_current_user();
if (in_array(‘subscriber’, $user->roles)) {
show_admin_bar(false);
}
}
meef
Godbless You. Answers to my problem always come from you post.
Thanks
Prem
Finally I got the answers Thank you
Paw Pet Directory
I used this on my directory for my customers but the bar will not go away for them. I am using 3.8 with AppThemes Vantage Theme (Latest)
Cory
This is one of those things that, because it’s such a small customization, I’d hate to use a plugin for. So being able to throw this short piece of code into my child theme’s functions.php made me super happy. Thanks so much far sharing! Works like a charm.
Raman
Thanks for posting it was useful.
Naveen
I have added this code it is working fine, but if a user takes meta there is an option yo view the admin, if i click on this the admin page can see, how to avoid this, i dont want to give admin panel to the users, a user can edit the url and give /wp-admin also he can see the admin, i dont want both what will do for this?
Subodh
Admin bar is hidden but now how can a user log out?
I am using bbpress forum and a plugin for users to log in via their Facebook account to join forum. But find no option for logging out.
WPBeginner Support
A link to the logout or login can be provided into sidebar or menus. WordPress comes with a default widget called meta which has login/logout link. Or you can add one to your site’s navigation menus. See our guide on how to show different menus to logged in users
Admin
Loralee
Thanks for the great tutorial. I thought it didn’t work – and then silly me I hadn’t followed the last step to activate my new plugin!! Thanks so much for this! So much better than installing multiple new plugins.
vikas
Thanks mate….u were really helpful…
tc
Rajat
Thx syed it just worked perfectly
Bongo
Thanks for this, it helped me a lot
Andy Wagstaff
I have an area of my site that requires log-in registration.
I have made the admin bar “autohide” by requiring a plug-in, I don’t want to entirely disable it, as I need the abiity to change password, but is there any way of removing items from the bar for users? I don’t want the site name,WP logo or the theme extensions options on the left hand side.
Is this possible? I am sure it is, but I can’t work it out!!
Ta!! Really handy site by the way
Andy
Rajiv
Hi,
I want to disable BP Admin Bar for Logged Out Users.
Please help.
Ken Shoufer
Hello,
Your code worked fine when I tried it locally on my computer, but when I tried it on a fresh Wordpress install on my host server it would not let me log out. When I tried to log out, the address showing was “http://www.ken-shoufer.com/wordpress1/wp-login.php?action=logout&_wpnonce=9e7f51a307”.
I’m not sure what is wrong.
Editorial Staff
That’s weird because we have it running on our live site.
Admin
Adrian
Thanks!
Fabio Santos
You can use this nice plugin instead: http://wordpress.org/plugins/global-admin-bar-hide-or-remove/
Nate
i am trying to disable the W logo on the top left, the “My Sites” menu and the dashboard link on a buddypress multisite install. I want to keep the right side functional which shows the links to their buddypress profile settings. How can I achieve this?
Tanner Moushey
To avoid the blank space where the admin bar was, call the function in the “after_setup_theme” action instead of “init”.
Cristian O. Balan
Really perfect, thanks a lot!
Will
Thank you so much! This worked perfectly and resolved several hours of head-scratching.
Cristian B.
Really nice code. Are here also a fix to the blank bar that many here complains?
David
Hi,
To avoid the blank, just instead of :
add_action(‘init’, ‘remove_admin_bar’);
use:
add_action(‘after_setup_theme’, ‘remove_admin_bar’);
Cristian O. Balan
Thanks a lot man!
niki
Fantastic! Except I also have the blank space visible where the admin bar would be. Does anyone have a fix for this?
Marlita Hill
Hello. Thank you for this. How would I write the code if I only want the bar accessible to admin and contributors? I still do not want the contributors to have admin access to my backend.
Steve
Well… it removes the admin bar but it´s still occupying the space meaning there´s too much space up there now. I´m not sure it´s supposed to be that way?
Adam
worked …
Thanks a lot
Nick Cokas
Add the code and worked perfect. However, the user still sees a white space above were the toolbar existed before. Any ideas to remove that.
Thanks
Toby Couchman
Did you use a plugin to place all the necessary user stuff on the frontend?
My team recently built a site with similar requirements and I’d love to compare the processes.
Cheers
Toby
Mark Coleman
Do not pass a role name to current_user_can(), as this is not guaranteed to work correctly. from
http://codex.wordpress.org/Function_Reference/current_user_can
just FYI
Editorial Staff
Agreed. Just updated the code to make it into a function, and then adding it in via action.
Admin
Sally
Excellent post thanks so much!
Took me under a minute and the bar was gone… forever… truly grateful.
Sally x
Corey Freeman
Thanks to this I have one less plugin bloating my site. Woo!
Delton Childs
This is an awesome post. short, to the point and contained a useful snippet! Thank you so much!
I’m using the S2Member plugin also, I was very concerned about compatibility issues with plugin based solutions because of the various s2Membership Levels. This solutions is working wonderfully for me.
Thanks Again!
James Davis
Hi Guys,
Just found this bit of code and it worked perfect for my site…
Thanks so much
Cheers
James
AKA The Fitness Blogger
glueckpress
Nice. For Superadmins in a Multisite install it would read like if(!current_user_can(‘manage_network’)) //etc.