Remove the WordPress admin bar

If you have a WordPress site with lots of users or you want to see your site as it looks for everyone else on the web, you probably want to remove the WordPress admin bar. There are plenty of legitimate reasons for doing this, and frankly, we feel it’s something that should be available within the WordPress dashboard at this point.

Removing the admin bar is also important if you have a membership-driven WordPress website. And even more so if you have multiple levels of users.

Remove the admin bar for everyone

Removing the admin bar for everyone is the simplest solution since as a WordPress administrator you have access to the dashboard anyway. Add this line to your functions.php file or inside a plugin:

show_admin_bar(false);

It’s that simple!

Remove the admin bar for everyone apart from administrators

As an administrator, you may want to see the admin bar while logged in but hide it for everyone else. Again, add this block of code to either your functions.php file or within a plugin:

add_action('after_setup_theme', 'disable_admin_bar');
 
function disable_admin_bar() {
  if (!current_user_can('administrator') and !is_admin()) {
    show_admin_bar(false);
  }
}

Now, as an administrator, you should still see the admin bar, but otherwise, it’ll be hidden for everyone else.

Leave a Reply

Your email address will not be published. Required fields are marked *

Up Next:

How to use Tailwind CSS with Nuxt

How to use Tailwind CSS with Nuxt