There are dozens of reasons to want to hide the WordPress admin bar. Hiding the admin bar is quite easy and can be done with one line of code. This removes the admin bar from everyone even the admins so you may want to conditionally hide the admin from specific users (roles) only.

One common use case is to hide the admin bar from users that don’t need to be able to go to the backend easily like customers in WooCommerce / Easy Digital Downloads.

There are some plugins available that will hide the admin bar for you, but as it is very easy to hide it via a small code snippet it is recommended to do it that way instead of using a plugin.

Hiding the admin bar

To hide the admin bar for everyone you can use the following line of code in your themes functions.php.

Quite easy right? This is the code that will remove the admin bar for every user (including yourself). If that was your intention, awesome! you can now stop reading the rest of this post. If you want to hide the admin bar conditionally, keep reading.

Hiding the admin bar for specific user roles

With the following snippet you can hide the admin bar only from the customer and author user roles. You can always add extra roles in the same way you’re seeing below.

Or if you only want the administrators to have the admin bar you can also change the code to do just that.

Hide only from certain users

The following snipper can be used to only hide the admin bar from certain users (based on their user ID).

Hiding the admin bar for your user

If you’re somehow not happy with the admin bar in the front end, there’s also a option you can un-check in order to hide the admin bar only from your account without using a code snippet.

wp-user-hide-admin-bar (1)Un-ticking the checkbox shown above will make sure that your user won’t show the admin bar in the front end of the site.

Jeroen Sormani

I'm a professional WordPress plugin developer on a mission to create the best plugins for my clients. I'm specialised in developing general WordPress, WooCommerce and Easy Digital Downloads plugins.

Interested in talking about a WordPress project? Get in touch!

Follow me on Twitter

3 thoughts on “Hiding the Admin Bar (Conditionally)

Jihn July 7, 2016 at 2:15 am

Thank you for this very much…

junvin October 21, 2016 at 11:52 am

thanks nice example….^^

Maria April 16, 2017 at 11:27 pm

Hi Jeroen,
great overview. Thanks a lot!

Leave a Reply