custom css for admin only

Question

I need custom CSS for admin. So if user is not logged in or is anything else but admin there is one CSS, and for admin only different CSS.

I tried this code in functions.php:

function wpa66834_role_admin_body_class( $classes ) {
    global $current_user;
    foreach( $current_user->roles as $role )
        $classes .= ' role-' . $role;
    return trim( $classes );
}
add_filter( 'admin_body_class', 'wpa66834_role_admin_body_class' );

and in custom CSS field:

#targetElement { 
    display: none; 
}
.role-administrator #targetElement { 
    display: visible; 
}

But it doesn’t work.

0
, Petra Zagar 3 years 2018-04-10T07:58:21-05:00 0 Answers 76 views 0

Leave an answer

Browse
Browse