How to hide the admin bar in WordPress (for everyone but admins)

Fixes & snippets

26 November 2026

How to hide the admin bar in WordPress (for everyone but admins)

One tested snippet hides the admin bar for everyone except administrators, plus a variant for editors and a way to keep customers out of wp-admin.

Tested on WordPress 7.1.5, PHP 8.5 and Avada 7.17, November 2026.

If your site has logged-in customers, members or clients, WordPress shows each of them the black admin bar across the top of your website. It looks unfinished, and it offers links into the dashboard they don’t need. Each user can switch it off in their own profile, but nobody does. One small snippet hides it for everyone except administrators.

The snippet: admins only

<?php
/**
 * Hide the admin bar on the front end for everyone except administrators.
 */
add_filter( 'show_admin_bar', function ( $show ) {
	return current_user_can( 'manage_options' ) ? $show : false;
} );

Administrators still see the bar (unless they’ve switched it off in their own profile). Everyone else, including editors and authors, doesn’t.

Keep it for editors and authors

If your team edits content and finds the bar’s “Edit page” link useful, show it to anyone who can edit posts instead. Subscribers and customers still won’t see it:

<?php
add_filter( 'show_admin_bar', function ( $show ) {
	return current_user_can( 'edit_posts' ) ? $show : false;
} );

Where to put it

Pick one of these. Don’t paste it into your theme’s functions.php unless it’s a child theme, because a theme update will wipe it.

  • A must-use plugin (my choice). Save the code as hide-admin-bar.php in wp-content/mu-plugins/ (create the folder if it doesn’t exist). It loads automatically and survives theme changes.
  • A code snippets plugin. Paste it in without the opening <?php line and activate it.
  • A child theme’s functions.php. Paste it without the opening <?php line.

Take a backup first. A typo in PHP can take the site down, and if it does, deleting the file you just added brings it straight back.

It only hides the bar on the front end

This is the part most guides miss. The snippet hides the bar on your website, but if a subscriber goes to /wp-admin/, they still get the dashboard, with the bar. If customers have no reason to be in there, add this as well. It sends anyone who can’t edit posts back to the home page:

<?php
/**
 * Keep users who can't edit posts out of wp-admin.
 */
add_action( 'admin_init', function () {
	if ( ! current_user_can( 'edit_posts' ) && ! wp_doing_ajax() ) {
		wp_safe_redirect( home_url( '/' ) );
		exit;
	}
} );

The wp_doing_ajax() check matters: plenty of plugins (forms, shops, membership plugins) send requests through admin-ajax.php, even for logged-out visitors, and blocking those would break them. If your users need their profile page in wp-admin, for example to change their password, give them a front-end account page instead before you add this.

How I tested it

I made a temporary subscriber, editor and administrator on a test site and loaded the home page and the profile screen as each one.

  • Before: all three saw the admin bar on the website and in wp-admin.
  • Admins-only snippet: the subscriber and the editor no longer saw it on the website; the administrator still did. All three still saw it in wp-admin.
  • Editors variant: only the subscriber lost it.
  • With the wp-admin redirect added: the subscriber was sent back to the home page when they opened their profile; editors and admins carried on as normal.
  • No snippet, but the editor unticked “Show Toolbar when viewing site” in their profile: it disappeared for that one user only, which is why the snippet is the reliable way to do it.

The test users and code were removed afterwards.

Common questions

Can I hide it without code?

Per user, yes: Users > Profile, untick Show Toolbar when viewing site. It’s fine for your own account, but you’d have to do it for every user, and new users get the bar by default.

Will it hide the bar for me too?

No. With the admins-only version, administrators keep the bar. If you want it gone for yourself as well, untick the box in your own profile.

Why is there a gap at the top of my site where the bar was?

WordPress adds a top margin for the bar. When the bar is hidden with the show_admin_bar filter, WordPress removes that margin too. If you still see a gap, your theme or a caching plugin is serving an old copy: clear the cache and check again.

Rather someone else did it?

Small jobs like this are included in my WordPress maintenance plans, along with updates, backups and monitoring.

Mark McKeown

Mark McKeown

Freelance WordPress developer in Belfast since 2015: 100+ sites, nearly all in Avada.

Need a hand with this?

Tell me what’s going on with your site. I reply within one working day.

More insights

  • How to disable comments in WordPress without a plugin

    Fixes & snippets

    24 Nov 2026

    How to disable comments in WordPress without a plugin

    The settings-only way, and one tested snippet that switches comments off everywhere for good.

  • How much does website maintenance cost in the UK?

    WordPress

    22 Nov 2026

    How much does website maintenance cost in the UK?

    Typical UK prices for website maintenance in 2026, what you should get at each level, and the hidden costs to watch for.

  • How to improve website speed on WordPress

    Speed

    22 Nov 2026

    How to improve website speed on WordPress

    What actually slows a WordPress site down, the fixes worth doing first, and the old tips that no longer make much difference.

Tell me about your project

New site, redesign, agency build or a fix that can't wait. I reply within one working day.