I'm looking to apply custom CSS in the admin only for a certain user role, "Contributor" to be exact.
Everything I try either seems to have no effect, or produces a 500 error.
What I've tried has in the main been loosely based around this:
add_action('admin_head', 'custom_admin_css');
function custom_admin_css( ){
global $user;
if (isset($user->roles) && is_array( $user->roles ) ) {
if( $user->roles[0] == 'administrator' ) {
//Do something
} elseif ( $user->roles[0] == 'editor' ) {
//Do something
} elseif ( $user->roles[0] == 'contributor') {
echo '<style> CSS </style>';
} else {
//Do something
}
}
}
edit
your question ( using the link above ) to add in what you've tried so far? – Howdy_McGee♦ Nov 7 '16 at 15:38.role-editor #targetElement { display:none }
– JHoffmann Nov 7 '16 at 16:39