以下是我以代码形式给出的答案:
<?php
// Customer Details
$args = array(
\'blog_id\' => $GLOBALS[\'blog_id\'],
\'role\' => \'customer\',
\'meta_key\' => \'last_name\',
\'meta_value\' => \'\',
\'meta_compare\' => \'\',
\'meta_query\' => array(),
\'date_query\' => array(),
\'include\' => array(),
\'exclude\' => array(),
\'orderby\' => \'last_name\',
\'order\' => \'ASC\',
\'offset\' => \'\',
\'search\' => \'\',
\'number\' => \'\',
\'count_total\' => false,
\'fields\' => \'all\',
\'who\' => \'\'
);
$bowlers = get_users( $args );
global $wpdb;
$games_left = $wpdb->get_results("SELECT id, user_id, sum(total_games) AS total_games, sum(games_played) AS games_played FROM `bowling_games` GROUP BY user_id");
?>
<div class="col-xs-12 col-sm-4">
<h2>Users with 0 Games left</h2>
<button><a href="" title="">Send Reminder to All</a></button>
<?php
foreach ( $games_left as $game_left ) {
$total_games = $game_left->total_games;
$games_played = $game_left->games_played;
$user_id = $game_left->user_id;
foreach ( $bowlers as $bowler ) {
if ( $user_id == $bowler->ID ) {
if ( ( $total_games - $games_played ) == 0 ) { ?>
<p><?php echo "User ID: " . $user_id . " Name: " . $bowler->first_name . " " . $bowler->last_name . " Email: " . $bowler->user_email . " Games Left: " . ( $total_games - $games_played ); ?></p>
<?php
}}
}
}
?>
</div>