WordPress User Roles zu den body Classes hinzufügen

[php]

/***********************************************************************
* ADD USER ROLES TO BODY CSS CLASSES
*
***********************************************************************
*/

function get_user_roles() {
global $current_user;

$user_roles = NULL;
$user_roles_array = $current_user->roles;

foreach ($user_roles_array as $user_role) {
if (!empty($user_role || $user_role != ‚ ‚)) {
$user_roles .= $user_role . ‚ ‚;
}
}

return $user_roles;
}

if ( is_user_logged_in() ) {
add_filter(‚body_class‘,’my_class_names‘);
}

function my_class_names($classes) {
$classes[] = get_user_roles();
return $classes;
}

[/php]

War dieser Artikel hilfreich?
Nach oben scrollen