The WordPress admin bar is a useful toolbar that appears at the top of your site for logged-in users, providing quick access to dashboard features, notifications, and shortcuts. However, for many site owners, especially those running membership sites, e-commerce stores, or multi-author blogs, the admin bar can be distracting or unnecessary for certain user roles. Whether you want to declutter your site’s frontend, improve user experience, or prevent non-admin users from accessing backend features, hiding the admin bar is a common requirement.
In this guide, you’ll learn three proven methods to hide the WordPress admin bar for specific user roles—or for everyone except administrators. We’ll cover plugin-based solutions, manual code snippets, and user profile settings, so you can choose the approach that best fits your needs.
Why Hide the WordPress Admin Bar?
The admin bar serves a purpose for administrators and editors, but it’s often redundant or even confusing for other user roles, such as subscribers, customers, or contributors. Here’s why you might want to hide it:
- Improved User Experience: The admin bar can disrupt the design of your site, especially on mobile devices or custom landing pages. Removing it creates a cleaner, more professional appearance for frontend users.
- Security and Focus: Non-admin users don’t need access to dashboard links or WordPress tools. Hiding the admin bar reduces the risk of accidental clicks and keeps users focused on your content or products.
- Customization for Membership Sites: If you run a membership site or online store, you may want to provide a seamless experience without exposing WordPress backend options to paying members or customers.
- Performance Optimization: Some themes and page builders render the admin bar in a way that conflicts with custom CSS or JavaScript, causing layout issues.
- Role-Based Access Control: You can tailor the admin bar’s visibility to specific roles, ensuring only those who need it can see it.
Below, we’ll walk through each method step by step, including best practices and troubleshooting tips.
Method 1: Hide the Admin Bar Using a Plugin (Recommended for Beginners)
Using a plugin is the easiest and safest way to hide the WordPress admin bar, especially if you’re not comfortable editing code. The Hide Admin Bar Based on User Roles plugin is the most popular choice, with over 40,000 active installations and a 4.5-star rating. It allows you to control admin bar visibility for each user role with just a few clicks.
Step 1: Install and Activate the Plugin
1. Log in to your WordPress dashboard and navigate to Plugins → Add New.
2. In the search bar, type “Hide Admin Bar Based on User Roles” and press Enter.
3. Click Install Now next to the plugin, then activate it.
Step 2: Configure Plugin Settings
1. After activation, go to Settings → Hide Admin Bar Settings.
2. You’ll see a list of all user roles (e.g., Administrator, Editor, Author, Contributor, Subscriber, Customer).
3. Check the boxes next to the roles for which you want to hide the admin bar. For example, if you only want administrators to see the bar, check all roles except Administrator.
4. Scroll down and click Save Changes.
The plugin will now hide the admin bar for the selected roles. No coding or further configuration is required.
Pros of Using a Plugin
- No Code Required: Ideal for beginners or those who prefer a user-friendly interface.
- Role-Specific Control: You can hide the admin bar for some roles while keeping it visible for others.
- Compatibility: Works with most WordPress themes and plugins, including WooCommerce, BuddyPress, and LearnDash.
- Easy to Revert: Simply deactivate the plugin to restore the admin bar for all users.
Method 2: Hide the Admin Bar Using Custom Code (For Developers)
If you prefer not to use a plugin, you can hide the admin bar by adding a custom code snippet to your theme’s functions.php file or a code snippets plugin. This method is lightweight and gives you full control over the logic.
Option A: Hide for All Users Except Administrators
Add the following code to your functions.php file or a code snippets plugin like WPCode:
function hide_admin_bar_for_non_admins() {
if (!current_user_can('administrator') && !is_admin()) {
show_admin_bar(false);
}
}
add_action('after_setup_theme', 'hide_admin_bar_for_non_admins');This snippet checks if the current user is not an administrator and not in the WordPress admin area. If both conditions are met, it hides the admin bar.
Option B: Hide for Specific User Roles
To hide the admin bar for specific roles (e.g., Subscriber and Customer), use this modified snippet:
function hide_admin_bar_for_specific_roles() {
$user = wp_get_current_user();
$restricted_roles = array('subscriber', 'customer');
if (array_intersect($restricted_roles, $user->roles) && !is_admin()) {
show_admin_bar(false);
}
}
add_action('after_setup_theme', 'hide_admin_bar_for_specific_roles');Replace 'subscriber' and 'customer' with the roles you want to target.
Option C: Hide for All Users (Including Admins)
If you want to hide the admin bar for everyone, including administrators, use this simpler snippet:
add_filter('show_admin_bar', '__return_false');Important Notes for Using Code
- Backup Your Site: Always back up your
functions.phpfile before making changes. A syntax error can break your site. - Use a Child Theme: If you’re editing
functions.php, do so in a child theme to avoid losing changes during theme updates. - Test Thoroughly: After adding the code, log in as different user roles to ensure the admin bar is hidden as intended.
- Clear Cache: If the admin bar is still visible, clear your WordPress cache and browser cache.
Method 3: Hide the Admin Bar via User Profile Settings
WordPress includes a built-in option to hide the admin bar for individual users. This method is useful if you only need to hide the bar for a few specific accounts.
Step 1: Edit the User Profile
1. Go to Users → All Users in your WordPress dashboard.
2. Hover over the user you want to edit and click Edit.
3. Scroll down to the Toolbar section (near the bottom of the profile page).
4. Uncheck the box labeled Show Toolbar when viewing site.
5. Click Update User to save the changes.
When to Use This Method
- You only need to hide the admin bar for a handful of users.
- You want to give users the option to toggle the admin bar on or off themselves.
- You’re testing changes before applying them site-wide.
However, this method is not scalable for sites with many users, as you’d need to edit each profile manually.
Advanced Customization: Hide the Admin Bar on Specific Pages
Sometimes, you may want to hide the admin bar only on certain pages, such as landing pages, checkout pages, or custom templates. You can achieve this with conditional logic in your code snippet.
Example: Hide on a Specific Page
Use this snippet to hide the admin bar on a page with the ID 123:
function hide_admin_bar_on_specific_page() {
if (is_page(123) && !current_user_can('administrator')) {
show_admin_bar(false);
}
}
add_action('after_setup_theme', 'hide_admin_bar_on_specific_page');Example: Hide on All WooCommerce Pages
To hide the admin bar on all WooCommerce pages (e.g., shop, cart, checkout), use:
function hide_admin_bar_on_woocommerce_pages() {
if (function_exists('is_woocommerce') && is_woocommerce() && !current_user_can('administrator')) {
show_admin_bar(false);
}
}
add_action('after_setup_theme', 'hide_admin_bar_on_woocommerce_pages');Example: Hide on Mobile Devices
If the admin bar is causing layout issues on mobile, you can hide it only for mobile users:
function hide_admin_bar_on_mobile() {
if (wp_is_mobile() && !current_user_can('administrator')) {
show_admin_bar(false);
}
}
add_action('after_setup_theme', 'hide_admin_bar_on_mobile'); Pro Tips for Hiding the WordPress Admin Bar
- Combine Methods for Flexibility: Use a plugin for role-based hiding and custom code for page-specific rules. This gives you the best of both worlds.
- Test with User Switching: Install the User Switching plugin to quickly log in as different user roles and verify the admin bar is hidden correctly.
- Check for Plugin Conflicts: Some plugins (e.g., WooCommerce, BuddyPress) modify the admin bar. Test after hiding it to ensure no functionality is broken.
- Use CSS as a Last Resort: If you can’t hide the admin bar with plugins or code, you can use CSS to hide it visually:
#wpadminbar { display: none !important; }Add this to Appearance → Customize → Additional CSS. Note that this only hides the bar visually—it’s still loaded in the background.
- Monitor Performance: If you notice slowdowns after hiding the admin bar, check for JavaScript errors or conflicts with your theme.
- Document Your Changes: Keep a record of which methods you’ve used, especially if you’re managing a multi-author site.
Frequently Asked Questions
1. Will hiding the admin bar affect my site’s functionality?
No, hiding the admin bar is purely cosmetic. All WordPress features will continue to work as usual. However, users who rely on the admin bar for quick access to dashboard links may need to navigate via the standard WordPress menu (/wp-admin).
2. Can I hide the admin bar for logged-out users?
The admin bar only appears for logged-in users, so there’s no need to hide it for guests. If you’re seeing the admin bar while logged out, it’s likely a caching issue or a plugin conflict.
3. Why is the admin bar still visible after using a plugin or code?
Common reasons include:
- Cached pages: Clear your WordPress cache and browser cache.
- Plugin conflicts: Deactivate other plugins to check for interference.
- Incorrect code placement: Ensure your snippet is in the correct file and wrapped in PHP tags.
- Theme overrides: Some themes load their own admin bar styles. Check your theme’s documentation.
4. Can I customize what appears in the admin bar instead of hiding it?
Yes! You can remove or add items to the admin bar using the admin_bar_menu hook. For example, to remove the WordPress logo:
function remove_wp_logo_from_admin_bar() {
global $wp_admin_bar;
$wp_admin_bar->remove_node('wp-logo');
}
add_action('wp_before_admin_bar_render', 'remove_wp_logo_from_admin_bar');5. Is it safe to edit the functions.php file?
Editing functions.php is safe if you follow best practices:
- Always back up your site before making changes.
- Use a child theme to avoid losing changes during updates.
- Test changes on a staging site first.
If you’re uncomfortable with code, stick to the plugin method.
6. Will hiding the admin bar improve my site’s speed?
The admin bar itself has minimal impact on performance. However, hiding it can reduce HTTP requests if you’re using CSS or JavaScript to modify its appearance.
7. Can I hide the admin bar for specific post types?
Yes, you can use conditional tags like is_singular('post_type') in your code snippet. For example:
function hide_admin_bar_for_custom_post_type() {
if (is_singular('portfolio') && !current_user_can('administrator')) {
show_admin_bar(false);
}
}
add_action('after_setup_theme', 'hide_admin_bar_for_custom_post_type');8. What’s the difference between the admin bar and the toolbar?
In WordPress, the terms “admin bar” and “toolbar” refer to the same thing. The official name is the Toolbar, but it’s commonly called the admin bar for clarity.
Conclusion
Hiding the WordPress admin bar is a simple yet effective way to improve your site’s appearance, enhance user experience, and maintain better control over backend access. Whether you choose a plugin for ease of use, custom code for flexibility, or user profile settings for granular control, the methods outlined in this guide will help you achieve your goals without compromising functionality.
For most users, the Hide Admin Bar Based on User Roles plugin is the best balance of convenience and power. Developers may prefer the code-based approach for finer control, while small sites can rely on manual profile edits. Whichever method you choose, always test your changes thoroughly and monitor for any unexpected behavior.
By following the steps and best practices in this guide, you can ensure the admin bar is only visible to those who truly need it—keeping your site clean, secure, and user-friendly.











