List custom rolenames in the WordPress Admin User List area
<?php
/**
* Display Custom Roles in WordPress Admin
*/
add_action('manage_users_custom_column', 'yanco_show_user_roles_column_content', 10, 3);
function yanco_show_user_roles_column_content($value, $column_name, $user_id) {
global $wp_roles;
$user = get_userdata( $user_id );
$user_roles = '';
if ( 'roles' == $column_name ) {
if ( !empty( $user->roles ) && is_array( $user->roles ) ) {
foreach ( $user->roles as $user_role ) {
foreach ( $wp_roles->role_names as $wp_role => $wp_role_name ) {
if($user_role == $wp_role) {
$user_roles .= $wp_role_name;
}
}
}
}
return $user_roles;
}
return $value;
}