Show the WordPress Admin Bar for Administrators Only

If you don’t want regular logged-in users of your site to see the admin bar, hiding it is very easy. This is especially useful for sites where users have to be logged in to comment but they don’t have much use for the dashboard.

Here’s a quick little trick I found at wp-snippets.com this week:

1
2
3
if (!current_user_can('administrator')) :
  show_admin_bar(false);
endif;

Add it to your theme’s functions.php file or create your own little mini-plugin for it, if that’s what you prefer. After you add it, the admin bar will be hidden from all logged-in users except administrators.

Comments (2)

  1. Hi,
    I have a theme with a narrow black bar of its own across the top. When I use this method I get a blank space of page background color above it where the admin bar would be if it was visible. Is there a way to fix that?

Participate