Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save terrytsang/2bab48e4227db36d6bac82dc32cf22ad to your computer and use it in GitHub Desktop.
Save terrytsang/2bab48e4227db36d6bac82dc32cf22ad to your computer and use it in GitHub Desktop.
How to hide WordPress Admin bar for all/non-admin users
<?php
//below code snippet is to be added to WordPress theme functions.php file
//option 1: remove the WordPress admin bar for all users
add_filter('show_admin_bar', '__return_false');
//option 2: hide the WordPress admin for everyone except users with administrator privileges
add_action('after_setup_theme', 'remove_admin_bar');
function remove_admin_bar() {
if (!current_user_can('administrator') && !is_admin()) {
show_admin_bar(false);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment