Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
WordPress Plugins
View all Guides

How to Disable WordPress Admin Bar for All Users Except Administrators

Last updated on by
Special WordPress Hosting offer for WPBeginner Readers
How to Disable WordPress Admin Bar for All Users Except Administrators

Recently while working on a membership site, we had to create multiple level of users. We did not want the users to have access to the WP-Admin panel because it was not customized for their experience. Rather we had put everything necessary (such as edit profile page), user dashboard etc, on the front-end. While S2 Membership Plugin allowed for us to disable wp-admin access for all users except for admins, there was no option to disable the admin bar by default. In this article, we will show you how to disable WordPress admin bar for all users except for Administrators.

Video Tutorial

If you don’t like the video or need more instructions, then continue reading.

Disable Admin Bar for All Users Except for Administrators

Paste this code in your theme’s functions.php file or your site-specific plugin.

add_action('after_setup_theme', 'remove_admin_bar');

function remove_admin_bar() {
if (!current_user_can('administrator') && !is_admin()) {

Disable Admin Bar for All Users

If you want to disable it for all users, then simply put use this code in your theme’s functions.php file or your site-specific plugin.

/* Disable WordPress Admin Bar for all users but admins. */

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »


  1. ronald osoo says:

    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 says:

      I agree, direct access to wp-admin/profile.php is making this useless.

      • Steve says:

        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 : Thats normal. I find it’s look really good without the adminbar.

  2. Alex S says:

    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.


    • WPBeginner Support says:

      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.

  3. Jenn says:

    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 says:

      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.


      • Jenn says:

        I just tried adding in the code for all users: show_admin_bar(false); and I can still see the admin bar.

  4. Alexander Pardo says:

    Thank you very much ! A very simple and clean solution. :)

  5. Jason A. Churchill says:

    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 says:

      At the end. If your functions.php file ends with ?> then you need to paste the code just before it.

  6. Terry Hale says:

    Thanks so much for this! No plugins, nice, clean, simple.

  7. WPBeginner Staff says:

    WordPress admin bar is displayed only for logged in users.

  8. Bhris says:

    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?

  9. Shashi says:

    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:

    • vipin says:

      Thanks a lot its really cool…………

    • Karen says:

      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.

  10. kim04099 says:

    Thank You!!

  11. Che Boielle says:

    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.

  12. Manthan says:

    Thanks, Its the easiest way found..!!!

  13. Ryan McGovern says:

    Thanks for the code snippet!

  14. Anup says:

    Why not simply do this for any specific user.

  15. Róger Marroni says:

    Great job man!

    thank you very much!

  16. Mega says:

    I tried and my site is black.

  17. Etienne says:

    Perfect piece of code… Thanks a lot!


  18. Nathan Jansen says:

    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)) {

  19. meef says:

    Godbless You. Answers to my problem always come from you post.


  20. Prem says:

    Finally I got the answers Thank you

  21. Paw Pet Directory says:

    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)

  22. Cory says:

    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.

  23. Raman says:

    Thanks for posting it was useful.

  24. Naveen says:

    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?

  25. Subodh says:

    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.

  26. Loralee says:

    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.

  27. vikas says:

    Thanks mate….u were really helpful…
    tc :-)

  28. Rajat says:

    Thx syed it just worked perfectly

  29. Bongo says:

    Thanks for this, it helped me a lot

  30. Andy Wagstaff says:

    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


  31. Rajiv says:


    I want to disable BP Admin Bar for Logged Out Users.

    Please help.

  32. Ken Shoufer says:


    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 “”.

    I’m not sure what is wrong.

  33. Adrian says:


  34. Fabio Santos says:
  35. Nate says:

    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?

  36. Tanner Moushey says:

    To avoid the blank space where the admin bar was, call the function in the “after_setup_theme” action instead of “init”.

  37. Cristian B. says:

    Really nice code. Are here also a fix to the blank bar that many here complains?

  38. niki says:

    Fantastic! Except I also have the blank space visible where the admin bar would be. Does anyone have a fix for this?

  39. Marlita Hill says:

    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.

  40. Steve says:

    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? ;-)

  41. Adam says:

    worked …
    Thanks a lot

  42. Nick Cokas says:

    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.


  43. Toby Couchman says:

    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.


  44. Mark Coleman says:

    Do not pass a role name to current_user_can(), as this is not guaranteed to work correctly. from

    just FYI

    • Editorial Staff says:

      Agreed. Just updated the code to make it into a function, and then adding it in via action.

  45. Sally says:

    Excellent post thanks so much!

    Took me under a minute and the bar was gone… forever… truly grateful.

    Sally :) x

  46. Corey Freeman says:

    Thanks to this I have one less plugin bloating my site. Woo!

  47. Delton Childs says:

    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!

  48. James Davis says:

    Hi Guys,

    Just found this bit of code and it worked perfect for my site…

    Thanks so much



    AKA The Fitness Blogger

  49. glueckpress says:

    Nice. For Superadmins in a Multisite install it would read like if(!current_user_can(‘manage_network’)) //etc.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.