Guide on How to Hide Admin bar without Plugin

Here's how to Hide Admin bar without Plugin

Enter the following code in functions.php that will work on all types of themes that will be used

Hide the admin bar for all users

add_filter('show_admin_bar', '__return_false');

Hide the admin bar for all users except administrators

function hide_wordpress_admin_bar($user){ 
return ( current_user_can( 'administrator' ) ) ? $user : false; 
} 
add_filter( 'show_admin_bar' , 'hide_wordpress_admin_bar');

Hide the admin bar for different roles

For more specific cases here, only adminstrators and editors appear.

function hide_wordpress_admin_bar($hide){ if ( !current_user_can( 'administrator' ) || !current_user_can('editor')) { return false; }
return $hide; }
add_filter( 'show_admin_bar' , 'hide_wordpress_admin_bar');


Hide the admin bar for specific user IDs

function hide_wordpress_admin_bar($hide){ 
$hide_for_users = array( 24, 6, 19, 84); 
if (in_array( get_current_user_id(), $hide_for_users ) ) { 
return false; 
} return $hide; }
add_filter( 'show_admin_bar' , 'hide_wordpress_admin_bar');



Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.