Created
October 23, 2019 11:14
-
-
Save raftaar1191/ee030ad811b159ae7dd9f03ddde0dc0e to your computer and use it in GitHub Desktop.
Hide the Wp-admin bar for all the user other then admin
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
/** | |
* Hide the Wp-admin for all the user other then admin | |
*/ | |
function buddyboss_child_wp_head_hide_admin_bar() { | |
if ( is_user_logged_in() ) { | |
global $current_user; | |
$roles = (array) $current_user->roles; | |
if ( ! in_array( 'administrator', $roles ) ) { | |
?> | |
<style> | |
#wpadminbar { | |
display: none!important; | |
} | |
.site-header { | |
border-top-width: 0 !important; | |
} | |
html { | |
margin-top: 0 !important; | |
} | |
</style> | |
<?php | |
} | |
} | |
} | |
add_action( 'wp_head', 'buddyboss_child_wp_head_hide_admin_bar', 100 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment