Hello and welcome!
Try using get_user_meta(). There are a number of basic examples in the user notes at the bottom of the page.
This link does not clearly show how to get a query in 2 or more mata_value, the code I use is:
<?php
// Lista os Usuarios que realizaram deposito
$user_query = new WP_User_Query(
array(
'meta_key' => 'ma_deposito',
'user_id' => 'ma_deposito',
'orderby' => 'meta_value',
'order' => 'ASC',
'number' => 10
) );// coluna e valor da coluna
// User Loop
if ( ! empty( $user_query->results ) ) {
_e('<div class="table-responsive">');
_e('<table class="table table-striped table-bordered table-hover table-condensed">');
_e('<tr>');
_e('<td class="active"><strong>Apelido</strong></td><td class="active"><strong>E-mail</strong></td><td class="active"><strong>Valor</strong></td>');
_e('</tr>');
foreach ( $user_query->results as $user ):
_e('<tr>');
_e( '<td class="">'.$user->user_nicename.'</td><td class="">'.$user->user_email.'</td><td class="'.$user->ma_deposito_css.'">R$ ' . $user->ma_deposito .',00</td>');
_e('</tr>');
endforeach;
_e('</tr>');
_e('</table>');
echo('<span class="pull-right"><strong>Total arrecadado:</strong> R$ '.$valortotal.',00 reais</span>');
_e('</div>');
} else {
echo '
<div class="table-responsive">
<table class="table">
<tr>
<td class="page-header alert alert-info text-center">Ainda não existe colaborações para este evento, seja o primeiro colaborador!. </td>
</tr>
</table>
</div>
';}?>
Here is an example of a user experiencing the same problem as me:
http://wordpress.stackexchange.com/questions/212190/issue-with-foreach-on-duplicate-meta-keys
You can either get all meta data for a user or that of a specific key. Within the user loop, get all of the user’s meta data with something like this:
$all_data = get_user_meta( $user->ID );
You could loop through the returned array and output every field, but there’s no telling what kind of data might be in the array. Most prefer to selectively output only certain values, for example:
echo "User's real name (last, first): {$all_data['last_name']}, {$all_data['first_name']}<br>\n";
Unless you are sure the specific meta key exists for all users, you should verify it’s existence first with array_key_exists().
BTW, I would suggest you not run HTML strings through translation functions like _e(). For example _e('</table>');. While it does end up echoing out the string, it’s not very efficient. Just use the echo statement in most cases. Even for strings that are translatable, no translation will occur unless the string is pre-defined in the default translation file. If you are writing a plugin that will be eventually translated, you need to specify your plugin’s text domain in all translation calls.
hi @bcworkz
Thanks for your help, I was able to solve it by creating a query and a LEFT JOIN, thanks for your help.