I am trying to count all of the users meeting multiple criteria. I have tried so many different things and cannot get it to work. Any help is much appreciated. Thank you.
add_shortcode('pbe_storecount', 'pbe_shopcounts');
function pbe_shopcounts($atts) {
$atts = shortcode_atts( array(
'state' => '',
'metavalue' => do_shortcode('[display_name]'),
'userrole' => '',
), $atts );
$getQuarter = do_shortcode('[usermeta key="current_quarter" user="717"]');
if ($getQuarter == '1'){
$currentQuarter = 'ranker_q1';
} elseif ($getQuarter == '2'){
$currentQuarter = 'ranker_q1_89';
} elseif ($getQuarter == '3'){
$currentQuarter = 'ranker_q1_90';
} elseif ($getQuarter == '4'){
$currentQuarter = 'ranker_q1_91';
} else {
$currentQuarter = '';
}
$user_ids = get_users( $args );
$args = array (
'role__in' => wp_parse_list( $atts['userrole'] ),
'fields' => 'ID', // retrieve just the IDs
'count_total' => false, // no need for FOUND_ROWS()
'meta_query' => array(
'relation' => 'AND',
array(
'meta_key' => 'Group',
'meta_value' => $atts['metavalue'],
'meta_compare' => '=',
),
array(
'meta_key' => $currentQuarter,
'meta_value' => 'High',
'meta_compare' => '=',
),
)
);
return 'There are <strong>' . count( $user_ids ) . ' High Performers</strong> for ' . $atts['metavalue'] . ' in ' . $atts['state'] . '!';}