{"id":919,"date":"2025-03-24T14:28:01","date_gmt":"2025-03-24T14:28:01","guid":{"rendered":"https:\/\/wpgeodirectory.com\/documentation\/article\/how-do-i-remove-the-wp-admin-bar-for-non-admin-users\/"},"modified":"2025-04-03T15:24:22","modified_gmt":"2025-04-03T14:24:22","slug":"how-do-i-remove-the-wp-admin-bar-for-non-admin-users","status":"publish","type":"gd_place","link":"https:\/\/wpgeodirectory.com\/documentation\/article\/code-snippets\/how-do-i-remove-the-wp-admin-bar-for-non-admin-users\/","title":{"rendered":"How do I remove the WP Admin bar for non-admin users?"},"content":{"rendered":"\n<p>Some themes add a WP admin bar for all users that are logged in.<br><img loading=\"lazy\" decoding=\"async\" class=\"attachment-large size-large\" src=\"https:\/\/wpgeodirectory.com\/documentation\/wp-content\/uploads\/2025\/03\/file-8gg8xZYRXk.png\" sizes=\"auto, (max-width: 370px) 100vw, 370px\" srcset=\"https:\/\/wpgeodirectory.com\/documentation\/wp-content\/uploads\/2025\/03\/file-8gg8xZYRXk.png 370w, https:\/\/wpgeodirectory.com\/documentation\/wp-content\/uploads\/2025\/03\/file-8gg8xZYRXk-300x118.png 300w\" alt=\"\" width=\"370\" height=\"145\"><\/p>\n\n\n\n<p>This code, if added using the <a href=\"https:\/\/wpgeodirectory.com\/documentation\/article\/useful-plugins\/code-snippets-plugin\/\">Code Snippets plugin<\/a>, will remove the admin bar for all users except for administrators:<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-php\">add_action(&#039;after_setup_theme&#039;, &#039;remove_admin_bar&#039;);\n\u00a0\nfunction remove_admin_bar() {\nif (!current_user_can(&#039;administrator&#039;) &amp;&amp; !is_admin()) {\n\u00a0\u00a0show_admin_bar(false);\n}\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Some themes add a WP admin bar for all users that are logged in. This code, if added using the Code Snippets plugin, will remove the admin bar for all users except for administrators:<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"article\/tags":[],"article\/categories":[211,432,433],"class_list":["post-919","gd_place","type-gd_place","status-publish","hentry","gd_placecategory-tips-tricks-more","gd_placecategory-how-tos","gd_placecategory-code-snippets"],"_links":{"self":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/919","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article"}],"about":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/types\/gd_place"}],"author":[{"embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/comments?post=919"}],"version-history":[{"count":0,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/919\/revisions"}],"wp:attachment":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/media?parent=919"}],"wp:term":[{"taxonomy":"gd_place_tags","embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/tags?post=919"},{"taxonomy":"gd_placecategory","embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/categories?post=919"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}