add_shortcode('user_role', function() { global $wp_roles; if( is_user_logged_in() ) { $user = wp_get_current_user(); $roles = ( array ) $user->roles; echo '<span>'; foreach( $roles as $role ){ echo $wp_roles->roles[ $role ]['name'] ; } } });
add_shortcode('user_role', function() { global $wp_roles; if( is_user_logged_in() ) { $user = wp_get_current_user(); $roles = ( array ) $user->roles; echo '<span>'; foreach( $roles as $role ){ echo $wp_roles->roles[ $role ]['name'] ; } } });