Steps
-
Add the PHP code to your child theme’s
functions.phpfile or the Code Snippets plugin. -
Save and activate the snippet.
-
Log in as a non-administrator to verify the admin bar is hidden on the front end.
Hook Used
– show_admin_bar — Controls whether the WordPress front-end admin bar is displayed.
Type: WordPress Admin Customization
Output: Administrators can still see the admin bar, while users without the manage_options capability cannot.
Note: This only hides the front-end admin bar. It does not prevent users from accessing the WordPress dashboard if their account permissions allow it.
function custom_hide_admin_bar_for_non_admins( $show ) {
if ( ! current_user_can( 'manage_options' ) ) {
return false;
}
return $show;
}
add_filter( 'show_admin_bar', 'custom_hide_admin_bar_for_non_admins' );
Tested on
Reported by the author on October 15, 2026. WPFolks has not verified this.
Not tested against WordPress 7.1.3. It may still work.