Created
September 27, 2016 16:48
-
-
Save atsea/4f1e24b3ea4c25f93fbb558a5171cf07 to your computer and use it in GitHub Desktop.
WordPress: check user role and add inline css
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
/** | |
* http://wordpress.stackexchange.com/questions/131814/if-current-user-is-admin-or-editor | |
* set wpadminbar to position fixed to work with UD Theme 8/29/15 CL | |
*/ | |
$user = wp_get_current_user(); | |
$allowed_roles = array('editor', 'administrator', 'author'); | |
if( array_intersect($allowed_roles, $user->roles ) ) | |
$custom_css = | |
"@media screen and (max-width:600px) {#wpadminbar {position: fixed !important;}}".'/n'; | |
"@media only screen and (max-width:48em) {#wpadminbar {position:fixed !important;}}".'/n'; | |
wp_add_inline_style( $this->sb_bar .'-admin-styles', $custom_css ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment