SOLVED.
I missed ID field in field array.
$args = array(
'role' => 'author',
'order' => 'DESC',
'orderby' => 'post_count',
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'medical_diagnosis',
'compare' => 'EXISTS',
),
array(
'key' ='gender',
'compare' => 'EXISTS',
),
),
'who' => 'authors',
'count_total' => true,
'fields' => array( 'ID', 'user_email', 'display_name'),
);
// The User Query
$users_query = new WP_User_Query( $args );
// The User Loop
if ( ! empty( $users_query->get_results() ) ) {
foreach ( $users_query->get_results() as $user ) {
// do something
// get all user meta at once:
$meta_for_user = get_user_meta( $user->ID);
$out="<p>users list</p>". $user->user_email . '<br />'. $user->display_name . $meta_for_user['medical_diagnosis'][0] . '<br />' . $meta_for_user['gender'][0] . '<br />'. $user->ID . $meta_for_user['last_name'][0] . '<br />';
return $out;
}
} else {
echo 'no users found';
}
} );