Last active
March 2, 2022 15:39
-
-
Save gerardreches/c86fa8e6062d40fa986db7c511653ca4 to your computer and use it in GitHub Desktop.
Hide WordPress admin bar for specific roles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function disable_admin_bar_for_roles() { | |
// Add here the roles you want to not have admin bar. | |
$excluded_roles = [ 'subscriber' ]; | |
return is_user_logged_in() && ! array_intersect( wp_get_current_user()->roles, $excluded_roles); | |
} | |
add_filter('show_admin_bar', 'disable_admin_bar_for_roles'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment