Aleš Sýkora / June 17, 2021 / 0 comments
Disable WordPress admin bar for all except admins
1 min read / WordPress / Share on: Twitter, LinkedIn, Facebook
Post summary: If you have your custom administration for users made with Toolset, you will propably need to hide the admin bar for your users except administrators. So if you have this question: “When you are logged in, the black wordpress top bar is showing up – is it possible to hide this bar for all users…
If you have your custom administration for users made with Toolset, you will propably need to hide the admin bar for your users except administrators. So if you have this question: “When you are logged in, the black wordpress top bar is showing up – is it possible to hide this bar for all users except the admin users?”
The answer is YES, you can hide admin panel with small snippet below:
// Your PHP code goes here!
add_action('after_setup_theme', 'remove_admin_bar');
function remove_admin_bar() {
if (!current_user_can('administrator') && !is_admin()) {
show_admin_bar(false);
}
}
Fuel my passion for writing with a beer🍺
Your support not only makes me drunk but also greatly motivates me to continue creating content that helps. Cheers to more discoveries and shared success. 🍻