You’re very close.
First, make sure you’re using unique variable names. I have set $current_seeking_id
for the meta key seeking_first
and $current_team_id
for the meta key team_manager
.
Next, you have to use these in your query to match. I’ve placed these variables at the value for your meta_query.
This assumes that the seeking_first
value matches the person_talent
value and the team_manager
value matches the team_number
value. This may not be the case and you may have to do some additional work for these to match.
$current_user_id = get_current_user_id();
$current_seeking_id = get_user_meta( $current_user_id, 'seeking_first', true );
$current_team_id = get_user_meta( $current_user_id, 'team_manager', true );
$args = array(
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'person_talent',
'value' => $current_seeking_id,
'compare' => '='
),
array(
'key' => 'team_number',
'value' => $current_team_id,
'compare' => '='
)
)
);
$user_query = new WP_User_Query( $args );
$results = $user_query->get_results();
if ( ! empty( $results ) ) {
echo '<ul>';
foreach ( $results as $user ) {
echo '<li>' . $user->first_name . ' - ' . $user->user_email . '</li>';
}
echo '</ul>';
} else {
echo 'No users found.';
}
Note: I also cleaned up the query result to set a variable for the get_results so as to only call this once. See $results = $user_query->get_results();