{"id":623,"date":"2025-06-16T09:34:13","date_gmt":"2025-06-16T07:34:13","guid":{"rendered":"https:\/\/wpcodebox.com\/?post_type=tutorial&#038;p=623"},"modified":"2025-12-19T21:18:51","modified_gmt":"2025-12-19T20:18:51","slug":"hide-admin-bar-wordpress","status":"publish","type":"tutorial","link":"https:\/\/wpcodebox.com\/tutorial\/hide-admin-bar-wordpress\/","title":{"rendered":"How to Hide the Admin Bar in WordPress"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The WordPress admin bar appears automatically for every logged-in user. While useful for site administrators, it confuses subscribers, customers, and members who don&#8217;t need backend access.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Many site owners want to hide this bar, but WordPress lacks a simple setting to disable it globally.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this article, I\u2019ll share how to hide the admin bar for specific user roles or remove it completely using a simple code snippet.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why You Should Hide the WordPress Admin Bar<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The default toolbar confuses non-technical users who don&#8217;t need access to backend links. The toolbar makes users feel like they are inside a backend system rather than browsing a finished website.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It acts as a gateway to areas users shouldn&#8217;t see. Even with restricted permissions, the admin bar provides direct links to the Dashboard and Profile screens. Curious users often click these links, which take them away from your content and into the confusing WordPress backend interface.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wpcodebox.com\/wp-content\/uploads\/2025\/06\/wordpress-admin-bar-at-the-top-1024x572.png\" data-rel=\"lightbox-image-0\" title=\"\" class=\"swipebox\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"572\" src=\"https:\/\/wpcodebox.com\/wp-content\/uploads\/2025\/06\/wordpress-admin-bar-at-the-top-1024x572.png\" alt=\"wordpress admin bar at the top\" class=\"wp-image-1648\" srcset=\"https:\/\/wpcodebox.com\/wp-content\/uploads\/2025\/06\/wordpress-admin-bar-at-the-top-1024x572.png 1024w, https:\/\/wpcodebox.com\/wp-content\/uploads\/2025\/06\/wordpress-admin-bar-at-the-top-300x168.png 300w, https:\/\/wpcodebox.com\/wp-content\/uploads\/2025\/06\/wordpress-admin-bar-at-the-top-768x429.png 768w, https:\/\/wpcodebox.com\/wp-content\/uploads\/2025\/06\/wordpress-admin-bar-at-the-top.png 1200w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The bar disrupts the user journey for membership sites and online stores. When a customer logs in to view their account or course content, a sudden black toolbar breaks their focus.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Manually Disable Admin Bar via User Settings<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You can control toolbar visibility individually through the WordPress dashboard. This method requires no code and works perfectly if you have limited users on the site.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Navigate to Users &gt; Profile in your admin dashboard and click on the profile you don\u2019t want to display the toolbar.<\/li>\n\n\n\n<li>Scroll down to the Toolbar option and uncheck the box labeled &#8220;Show Toolbar when viewing site&#8221;.<\/li>\n\n\n\n<li>Click Update Profile at the bottom of the page.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wpcodebox.com\/wp-content\/uploads\/2025\/06\/manually-hide-admin-for-individual-user-1024x484.png\" data-rel=\"lightbox-image-1\" title=\"\" class=\"swipebox\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"484\" src=\"https:\/\/wpcodebox.com\/wp-content\/uploads\/2025\/06\/manually-hide-admin-for-individual-user-1024x484.png\" alt=\"manually hide admin for individual user\" class=\"wp-image-1649\" srcset=\"https:\/\/wpcodebox.com\/wp-content\/uploads\/2025\/06\/manually-hide-admin-for-individual-user-1024x484.png 1024w, https:\/\/wpcodebox.com\/wp-content\/uploads\/2025\/06\/manually-hide-admin-for-individual-user-300x142.png 300w, https:\/\/wpcodebox.com\/wp-content\/uploads\/2025\/06\/manually-hide-admin-for-individual-user-768x363.png 768w, https:\/\/wpcodebox.com\/wp-content\/uploads\/2025\/06\/manually-hide-admin-for-individual-user.png 1200w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The bar disappears immediately for the account you made the change for. However, this setting doesn\u2019t apply to other users automatically. You\u2019ll need to individually uncheck the option for each user on your site. For membership sites or stores with many users, this is not practical, and you need something that applies this rule globally.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Hide the Admin Bar for Everyone Using a Code Snippet<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You can completely remove the toolbar for all users, including administrators. This is ideal when you&#8217;re developing a site and want to view the frontend exactly as a visitor sees it, without logging out constantly.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">add_filter('show_admin_bar', '__return_false');<\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">This single line of code disables the toolbar globally. Once active, no user will see the admin bar on the frontend. Administrators can still access the dashboard by visiting the \/wp-admin\/ URL directly.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How to Hide the Admin Bar for Non-Admins<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Hiding the bar for everyone is often too restrictive. As an administrator, you need the toolbar for quick access to site settings and content editing. Your subscribers and customers, however, should never see it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This snippet selectively hides the bar based on user roles. It checks if the current user has administrative permissions. If they don&#8217;t, the toolbar disappears.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">if (!current_user_can('administrator') &amp;&amp; !is_admin()) {\n    show_admin_bar(false);\n}<\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">This intelligent filter gives you the best of both worlds. You retain your management options while delivering a clean, professional experience to your users. Members and customers browse a distraction-free site, while you manage it efficiently from the frontend.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step-by-Step: Adding the Snippet to Your Website<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">You can add these snippets to your theme&#8217;s functions.php file, but theme updates will wipe out your changes instantly. You also risk crashing your site with a simple syntax error.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A snippet plugin is&nbsp;a much better solution in such cases. I&#8217;ll recommend using <a href=\"https:\/\/wpcodebox.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">WPCodeBox<\/a>, as it eliminates these risks by running your code safely in an isolated environment. This ensures your snippets remain active even when you change themes, and the plugin\u2019s built-in error protection automatically disables bad code before it breaks your site.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wpcodebox.com\/wp-content\/uploads\/2025\/12\/wpcodebox-snippet-plugin-1024x588.png\" data-rel=\"lightbox-image-2\" title=\"\" class=\"swipebox\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"588\" src=\"https:\/\/wpcodebox.com\/wp-content\/uploads\/2025\/12\/wpcodebox-snippet-plugin-1024x588.png\" alt=\"wpcodebox snippet plugin\" class=\"wp-image-1606\" srcset=\"https:\/\/wpcodebox.com\/wp-content\/uploads\/2025\/12\/wpcodebox-snippet-plugin-1024x588.png 1024w, https:\/\/wpcodebox.com\/wp-content\/uploads\/2025\/12\/wpcodebox-snippet-plugin-300x172.png 300w, https:\/\/wpcodebox.com\/wp-content\/uploads\/2025\/12\/wpcodebox-snippet-plugin-768x441.png 768w, https:\/\/wpcodebox.com\/wp-content\/uploads\/2025\/12\/wpcodebox-snippet-plugin.png 1200w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">It also comes with a cloud sync feature that lets you store snippets in the cloud and use them across all your WordPress sites. You can manage everything from a single dashboard and use the conditional logic builder to control exactly where your code runs. It replaces dozens of single-purpose plugins with one professional plugin.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now that you know why it\u2019s better to use WPCodeBox, let\u2019s look at how to add the snippet using the plugin:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Install and activate WPCodeBox from your WordPress Plugins menu.<\/li>\n\n\n\n<li>Navigate to WPCodeBox 2 from your admin sidebar to open the code editor.<\/li>\n\n\n\n<li>Name your snippet &#8220;Hide Admin Bar&#8221; so you can find it easily.<\/li>\n\n\n\n<li>Paste the conditional snippet from the previous section into the editor.<\/li>\n\n\n\n<li>Configure these settings:\n<ul class=\"wp-block-list\">\n<li>Type: PHP Snippet<\/li>\n\n\n\n<li>How to run the snippet: Always (On Page Load)<\/li>\n\n\n\n<li>Where to insert the snippet: Plugins Loaded (Default)<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Click Save to store your snippet in a disabled state and then review it to ensure you copied it correctly.<\/li>\n\n\n\n<li>Lastly, enable the snippet to hide the WordPress admin bar immediately.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wpcodebox.com\/wp-content\/uploads\/2025\/06\/wordpress-snippet-to-hide-admin-for-all-except-admins-1024x531.png\" data-rel=\"lightbox-image-3\" title=\"\" class=\"swipebox\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"531\" src=\"https:\/\/wpcodebox.com\/wp-content\/uploads\/2025\/06\/wordpress-snippet-to-hide-admin-for-all-except-admins-1024x531.png\" alt=\"WordPress snippet to hide admin for all except admins\" class=\"wp-image-1650\" srcset=\"https:\/\/wpcodebox.com\/wp-content\/uploads\/2025\/06\/wordpress-snippet-to-hide-admin-for-all-except-admins-1024x531.png 1024w, https:\/\/wpcodebox.com\/wp-content\/uploads\/2025\/06\/wordpress-snippet-to-hide-admin-for-all-except-admins-300x156.png 300w, https:\/\/wpcodebox.com\/wp-content\/uploads\/2025\/06\/wordpress-snippet-to-hide-admin-for-all-except-admins-768x398.png 768w, https:\/\/wpcodebox.com\/wp-content\/uploads\/2025\/06\/wordpress-snippet-to-hide-admin-for-all-except-admins.png 1200w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Your rule is now active, and WPCodeBox ensures this customization persists through all future theme updates and WordPress upgrades.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How to Verify the Admin Bar is Gone<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To verify the changes, open your website in a new private browser window and log in with a Subscriber or Customer account. The black toolbar should be completely absent from the top of the page.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Next, verify your own access. Stay logged in as an Administrator in your main browser window and refresh the frontend. You should still see the admin bar, confirming the conditional logic is working correctly.<br>You can also use the <a href=\"https:\/\/wordpress.org\/plugins\/user-switching\/\" target=\"_blank\" rel=\"noreferrer noopener\">User Switching<\/a> plugin to switch between different users without having to manually log in to each account.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">More on Hiding WordPress Admin Bar<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>1. How to hide admin menu items for specific users in WordPress?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Identify the menu slug for the section you want to hide.<\/li>\n\n\n\n<li>Add a PHP function to the&nbsp;<code>admin_menu<\/code>&nbsp;hook.<\/li>\n\n\n\n<li>Check if the current user is a non-administrator.<\/li>\n\n\n\n<li>Use the&nbsp;<code>remove_menu_page()<\/code>&nbsp;function to block the slug.<\/li>\n\n\n\n<li>Activate the snippet to clean up the sidebar for those users.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>2. How do I disable the WordPress dashboard for users?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can block backend access by redirecting specific roles to your homepage. You&#8217;ll use a PHP snippet that checks if a user is trying to access&nbsp;<code>\/wp-admin\/<\/code>&nbsp;without administrative permissions. If they aren&#8217;t an admin, the code automatically sends them back to the frontend, ensuring they never see your backend.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">More Ways to Customize Your WordPress Website<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/wpcodebox.com\/snippet\/change-wordpress-login-logo\/\" data-type=\"link\" data-id=\"https:\/\/wpcodebox.com\/snippet\/change-wordpress-login-logo\/\" target=\"_blank\" rel=\"noreferrer noopener\">Change WordPress Login Logo<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/wpcodebox.com\/snippet\/how-to-remove-wordpress-dashboard-widgets\/\" data-type=\"link\" data-id=\"https:\/\/wpcodebox.com\/snippet\/how-to-remove-wordpress-dashboard-widgets\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to Remove WordPress Dashboard Widgets<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/wpcodebox.com\/snippet\/how-to-hide-admin-notifications-in-wordpress\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to Hide Admin Notifications in WordPress<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/wpcodebox.com\/snippet\/how-to-disable-theme-and-plugin-editors-in-wordpress\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to Disable Theme and Plugin Editors in WordPress<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/wpcodebox.com\/snippet\/remove-wordpress-version-number\/\" data-type=\"link\" data-id=\"https:\/\/wpcodebox.com\/snippet\/remove-wordpress-version-number\/\" target=\"_blank\" rel=\"noreferrer noopener\">Remove WordPress Version Number<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to hide the admin bar from your WordPress frontend using a snippet in WPCodeBox!<\/p>\n","protected":false},"featured_media":624,"template":"","meta":{"_acf_changed":false},"tutorial-category":[8],"class_list":["post-623","tutorial","type-tutorial","status-publish","has-post-thumbnail","hentry","tutorial-category-how-to"],"acf":[],"_links":{"self":[{"href":"https:\/\/wpcodebox.com\/wp-json\/wp\/v2\/tutorial\/623","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wpcodebox.com\/wp-json\/wp\/v2\/tutorial"}],"about":[{"href":"https:\/\/wpcodebox.com\/wp-json\/wp\/v2\/types\/tutorial"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wpcodebox.com\/wp-json\/wp\/v2\/media\/624"}],"wp:attachment":[{"href":"https:\/\/wpcodebox.com\/wp-json\/wp\/v2\/media?parent=623"}],"wp:term":[{"taxonomy":"tutorial-category","embeddable":true,"href":"https:\/\/wpcodebox.com\/wp-json\/wp\/v2\/tutorial-category?post=623"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}