WordPress – How to disable the admin bar for all users

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

This isn’t desirable for a lot of WordPress users, for example a site where visitors log in as registered users or authors, but are not intended to access the administrative features of WordPress.

The following bits of code can be added to your theme’s functions.php file to control when the admin bar appears. Ensure you add the code between an existing <?php  … ?> block, for example add to the bottom of the file right before the ?>

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' );

WordPress-DisableAdminBar1