How to disable the admin bar for all users

By default WordPress displays a toolbar (known as the admin bar) on all pages when users are logged in.

This isn’t necessary for a lot of WordPress sites, for example where visitors log in as members, but are not intended to access the administrative features of WordPress.

The following code shows how to disable the admin bar.

If you haven’t already I suggest you create a custom plugin for holding any custom PHP code.

Disable the admin bar for non-admin users

/* Disable the admin bar for non-admin users */
if ( !current_user_can( 'manage_options' ) ) {
  add_filter( 'show_admin_bar', '__return_false' );
}

Disable the admin bar for all logged in users

/* Disable the admin bar for all logged in users */ 
add_filter( 'show_admin_bar', '__return_false' );

Was this article helpful?

Related Articles