How to Hide the WordPress Admin Bar for Subscribers Without a Plugin

How to Hide the WordPress Admin Bar for Subscribers Without a Plugin

When users log into your WordPress site—whether they are members of a paid community, ecommerce customers on WooCommerce, or registered students on an LMS platform—WordPress renders the dark 32-pixel admin toolbar across the very top of their screen by default.

For standard subscribers with no dashboard privileges, this top bar looks cluttered, clashes with custom frontend navigation, and exposes unnecessary links to WordPress profile screens. In this guide, you will learn how to hide the admin bar for non-administrators using a clean PHP filter, backed by official WordPress API documentation.

WordPress frontend header comparison showing subscriber view with admin bar hidden
Hide WordPress Admin Bar for Subscribers

Why You Should Avoid Bloated Plugins for This Task

Many WordPress users install third-party utility plugins to toggle the admin bar off. However, adding plugins for simple conditional UI tasks introduces unnecessary database checks, asset loading, and plugin maintenance overhead. WordPress provides a native function specifically built to control toolbar visibility programmatically: show_admin_bar().

The Clean PHP Method: Conditional show_admin_bar Filter

As documented in the WordPress Developer Reference for show_admin_bar(), you can disable the toolbar on the frontend while preserving it for administrators by hooking into after_setup_theme:

<?php
/**
 * Hide the WordPress Admin Bar for Subscribers and Non-Administrators
 * Documentation: https://developer.wordpress.org/reference/functions/show_admin_bar/
 */
function netutility_disable_subscriber_admin_bar() {
    if (!current_user_can('administrator') && !is_admin()) {
        show_admin_bar(false);
    }
}
add_action('after_setup_theme', 'netutility_disable_subscriber_admin_bar');

How This Code Functions

  • current_user_can('administrator'): Checks if the currently logged-in user possesses administrative privileges using WordPress’s current_user_can() function.
  • !is_admin(): Ensures that if an authorized user accesses the backend dashboard (/wp-admin/), the toolbar continues to render normally.
  • show_admin_bar(false): Instructs the WordPress template hierarchy not to inject the toolbar HTML or the 32px body margin offset on the frontend.
James Parker

James Parker

James Parker is a technology writer and WordPress enthusiast who shares practical guides on SEO, web development, AI tools, and digital growth. He focuses on creating easy-to-follow tutorials that help beginners and professionals build better websites and improve their online presence.