Last active
October 17, 2022 07:32
-
-
Save audrasjb/5eebbe6829bdd9f95bf666f83145a9c9 to your computer and use it in GitHub Desktop.
Hide admin bar in certain condition – for Christophe Glaudel (WP Academy Facebook group)
This file contains hidden or 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
<?php | |
/* | |
* Removes admin bar on front-end for everyone except admins. | |
* @audrasjb | |
*/ | |
function jba_remove_admin_bar( $show_admin_bar ) { | |
if ( ! current_user_can( 'administrator' ) && ! is_admin() ) { | |
$show_admin_bar = false; | |
} | |
return $show_admin_bar; | |
} | |
add_filter( 'show_admin_bar' , 'jba_remove_admin_bar'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment