{"id":32014,"date":"2021-03-11T12:19:22","date_gmt":"2021-03-11T12:19:22","guid":{"rendered":"https:\/\/beastthemes.com\/?p=32014"},"modified":"2021-03-11T12:19:22","modified_gmt":"2021-03-11T12:19:22","slug":"hide-admin-bar-based-on-user-roles","status":"publish","type":"post","link":"https:\/\/beastthemes.com\/new\/2021\/03\/11\/hide-admin-bar-based-on-user-roles\/","title":{"rendered":"4 Ways to Hide Admin Bar based on User Roles in WordPress"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"32014\" class=\"elementor elementor-32014\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-35920a43 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"35920a43\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-41bac677\" data-id=\"41bac677\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-1c3536df elementor-widget elementor-widget-text-editor\" data-id=\"1c3536df\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t\n<p class=\"wp-block-paragraph\">Do you want to easily hide admin bar based on user roles in WordPress?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">By default,&nbsp;<strong>you&#8217;ll&nbsp;<\/strong>easily disable the WordPress admin bar for any user from the dashboard. But this method can take time if&nbsp;<strong>you&#8217;ve got&nbsp;<\/strong><strong>tons&nbsp;<\/strong>of registered users on your site.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this article, we\u2019ll show&nbsp;<strong>you ways&nbsp;<\/strong>to disable the WordPress admin bar for all users except administrators.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>What is WordPress Admin Bar?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">By default, WordPress displays an admin bar on&nbsp;<strong>the top<\/strong>&nbsp;for all logged-in users. This toolbar is visible&nbsp;<strong>within the&nbsp;<\/strong>WordPress admin area&nbsp;<strong>also&nbsp;<\/strong>like all other pages&nbsp;<strong>once you&nbsp;<\/strong>are logged in.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"541\" src=\"https:\/\/beastthemes.com\/wp-content\/uploads\/2021\/03\/frontend-view-1024x541.png\" alt=\"hide admin bar based on user roles\" class=\"wp-image-32017\" title=\"Admin bar view image\" srcset=\"https:\/\/beastthemes.com\/new\/wp-content\/uploads\/2021\/03\/frontend-view-1024x541.png 1024w, https:\/\/beastthemes.com\/new\/wp-content\/uploads\/2021\/03\/frontend-view-300x158.png 300w, https:\/\/beastthemes.com\/new\/wp-content\/uploads\/2021\/03\/frontend-view-768x406.png 768w, https:\/\/beastthemes.com\/new\/wp-content\/uploads\/2021\/03\/frontend-view-1536x811.png 1536w, https:\/\/beastthemes.com\/new\/wp-content\/uploads\/2021\/03\/frontend-view-600x317.png 600w, https:\/\/beastthemes.com\/new\/wp-content\/uploads\/2021\/03\/frontend-view.png 1653w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption>This is my site ( <a href=\"https:\/\/beastthemes.com\/\" class=\"rank-math-link\">https:\/\/beastthemes.com\/<\/a> ) frontend view as a logged in user.<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The WordPress admin toolbar contains useful shortcuts to different WordPress sections. The shortcuts available&nbsp;<strong>within the&nbsp;<\/strong>admin bar change&nbsp;<strong>supported&nbsp;<\/strong>a users\u2019 role and permissions in WordPress.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">However, when viewing&nbsp;<strong>the general public&nbsp;<\/strong>pages on the front-end of your website, the admin bar&nbsp;<strong>is often&nbsp;a touch&nbsp;<\/strong>distracting.&nbsp;<strong>it&#8217;s going to&nbsp;<\/strong>also affect your website\u2019s design and user experience.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Luckily, there are multiple ways&nbsp;<strong>to simply&nbsp;<\/strong>disable the WordPress admin bar for all users except administrators.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Method 1. Disabling The WordPress Admin Bar for Any User<\/strong><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">WordPress allows each user to hide admin bar based on user roles by simply editing their user profile. As a site owner,&nbsp;<strong>you&#8217;ll&nbsp;<\/strong>also edit other user\u2019s profiles and disable the admin bar for them.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If&nbsp;<strong>you would like&nbsp;<\/strong>to disable the admin bar for any particular user in WordPress, you\u2019ll&nbsp;<strong>got to&nbsp;<\/strong>edit their user profile.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Simply&nbsp;<strong>attend&nbsp;<\/strong>the Users \u00bb All Users page&nbsp;<strong>then&nbsp;<\/strong>click on the \u2018edit\u2019 link for any user&nbsp;<strong>you would like&nbsp;<\/strong>to disable the admin bar for.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"550\" height=\"189\" src=\"https:\/\/beastthemes.com\/wp-content\/uploads\/2021\/03\/edit-user.png\" alt=\"user edit view\" class=\"wp-image-32018\" title=\"user edit view\" srcset=\"https:\/\/beastthemes.com\/new\/wp-content\/uploads\/2021\/03\/edit-user.png 550w, https:\/\/beastthemes.com\/new\/wp-content\/uploads\/2021\/03\/edit-user-300x103.png 300w\" sizes=\"(max-width: 550px) 100vw, 550px\" \/><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">This will bring you to the user profile editor page. From here, uncheck the box next to the \u2018Show toolbar when viewing site\u2019 option.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"547\" height=\"89\" src=\"https:\/\/beastthemes.com\/wp-content\/uploads\/2021\/03\/disable-admin-bar.png\" alt=\"user edit view second\" class=\"wp-image-32019\" title=\"user edit view second\" srcset=\"https:\/\/beastthemes.com\/new\/wp-content\/uploads\/2021\/03\/disable-admin-bar.png 547w, https:\/\/beastthemes.com\/new\/wp-content\/uploads\/2021\/03\/disable-admin-bar-300x49.png 300w\" sizes=\"(max-width: 547px) 100vw, 547px\" \/><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Scroll down and click the \u2018Update User\u2019 button to save your changes.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This will disable the admin bar for that particular user when they visit the website.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Luckily, there are other ways to quickly disable the admin bar for all users except administrators.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Method 2. Disable Admin Bar for All Users Except Administrators Using Code<\/strong><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">This method requires you&nbsp;<strong>to feature&nbsp;<\/strong>code to your WordPress theme files. If&nbsp;<strong>you&#8217;ve got&nbsp;<\/strong>not done this before, then check out this guide on&nbsp;<a aria-label=\" (opens in a new tab)\" href=\"https:\/\/www.wpbeginner.com\/beginners-guide\/beginners-guide-to-pasting-snippets-from-the-web-into-wordpress\/\" target=\"_blank\" rel=\"noreferrer noopener\" class=\"rank-math-link\">how to copy and paste code snippets in WordPress<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Simply add the following code to your theme\u2019s&nbsp;functions.php&nbsp;file<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>add_action('after_setup_theme', 'remove_admin_bar');\nfunction remove_admin_bar() {\nif (!current_user_can('administrator') &amp;&amp; !is_admin()) {\n  show_admin_bar(false);\n}\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This code checks if&nbsp;<strong>the present&nbsp;<\/strong>user&nbsp;<strong>isn&#8217;t&nbsp;<\/strong>an administrator,&nbsp;<strong>and that they&nbsp;aren&#8217;t&nbsp;<\/strong>viewing the admin dashboard. If both conditions match, then&nbsp;<strong>it&#8217;ll&nbsp;<\/strong>hide admin bar based on user roles.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Don\u2019t forget&nbsp;<strong>to save lots of&nbsp;<\/strong>your changes and check your website&nbsp;<strong>to form&nbsp;<\/strong>sure everything&nbsp;<strong>is functioning&nbsp;<\/strong>fine.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Method 3. Disable Admin Bar for All Users Including Admins<\/strong><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">What if you wanted to hide admin bar based on user roles including yourself and&nbsp;<strong>the other&nbsp;<\/strong>administrator on your site?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can&nbsp;<strong>do that&nbsp;<\/strong>by modifying the code we showed earlier.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Simply add the following code to your theme\u2019s&nbsp;functions.php&nbsp;file.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/* Disable WordPress Admin Bar for all users *\/\nadd_filter( 'show_admin_bar', '__return_false' );<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This code will disable the admin bar for all users when viewing the public pages of your website. All users will still be able to see the toolbar inside the WordPress admin dashboard.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Method 4. Disable Admin Bar for All Users Except Admins with a Plugin<\/strong><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">This method allows you to quickly hide admin bar based on user roles in WordPress.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">First, you need to install and activate the&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/wordpress.org\/plugins\/hide-admin-bar-based-on-user-roles\/\" target=\"_blank\" class=\"rank-math-link\">Hide Admin Bar Based on User Roles<\/a>&nbsp;plugin.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Upon activation, go to the&nbsp;<strong>Settings \u00bb Hide Admin Bar Settings<\/strong>&nbsp;page. From here, check the boxes next to the user roles where you want to disable the admin bar.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"550\" height=\"380\" src=\"https:\/\/beastthemes.com\/wp-content\/uploads\/2021\/03\/hide-admin-settings.png\" alt=\"hide admin bar based on user roles\" class=\"wp-image-32023\" title=\"hide admin bar based on user roles\" srcset=\"https:\/\/beastthemes.com\/new\/wp-content\/uploads\/2021\/03\/hide-admin-settings.png 550w, https:\/\/beastthemes.com\/new\/wp-content\/uploads\/2021\/03\/hide-admin-settings-300x207.png 300w\" sizes=\"(max-width: 550px) 100vw, 550px\" \/><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Don\u2019t forget to click on the \u2018Save Changes\u2019 button to store your settings.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We hope this article helped you learn how to hide admin bar based on user roles in WordPress.<\/p>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>Do you want to easily hide admin bar based on user roles in WordPress? By default,&nbsp;you&#8217;ll&nbsp;easily disable the WordPress admin [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":32029,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[20,21,24],"tags":[27,28],"class_list":["post-32014","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-beginners-guide","category-plugins","category-wordpress","tag-admin-bar","tag-hide-admin-bar"],"_links":{"self":[{"href":"https:\/\/beastthemes.com\/new\/wp-json\/wp\/v2\/posts\/32014","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/beastthemes.com\/new\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/beastthemes.com\/new\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/beastthemes.com\/new\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/beastthemes.com\/new\/wp-json\/wp\/v2\/comments?post=32014"}],"version-history":[{"count":0,"href":"https:\/\/beastthemes.com\/new\/wp-json\/wp\/v2\/posts\/32014\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/beastthemes.com\/new\/wp-json\/wp\/v2\/media\/32029"}],"wp:attachment":[{"href":"https:\/\/beastthemes.com\/new\/wp-json\/wp\/v2\/media?parent=32014"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/beastthemes.com\/new\/wp-json\/wp\/v2\/categories?post=32014"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/beastthemes.com\/new\/wp-json\/wp\/v2\/tags?post=32014"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}