Skip to content
All articles

HOW to Disable WordPress Admin Bar for All Users?

1 min read

Today, when I went to take a screenshot of one admin screen, It also comes with “Admin Bar”. So, I realize that I don’t need an admin bar and I started looking into the code to disable Admin Bar.

Finally, I came to know the solution.

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()) {
    show_admin_bar(false);
  }
}

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

show_admin_bar(false);

Have a problem worth solving?

That’s my favourite kind of conversation. Tell me what you’re up against — let’s figure it out together.