/**
  * Returns all user points records
  *
  * @since 1.0
  * @param $args array arguments for the user query
  * @return array of user_points objects with user_id and points_balance fields
  */
 public static function get_all_users_points($args)
 {
     if (!isset($args['fields'])) {
         $args['fields'] = 'ID';
     }
     $args['meta_key'] = 'wc_points_balance';
     // perform the user query, altering the orderby as needed when ordering by user points
     if ('points' === $args['orderby']) {
         add_action('pre_user_query', array(__CLASS__, 'order_user_by_points'));
     }
     $wp_user_query = new WP_User_Query($args);
     if ('points' === $args['orderby']) {
         remove_action('pre_user_query', array(__CLASS__, 'order_user_by_points'));
     }
     // record the total result set (for pagination purposes)
     if (isset($args['count_total']) && $args['count_total']) {
         self::$found_users = $wp_user_query->get_total();
     }
     $results = array();
     // build the expected user points records
     foreach ($wp_user_query->get_results() as $user_id) {
         $result = new stdClass();
         $result->user_id = $user_id;
         $result->points_balance = self::get_users_points($user_id);
         $results[] = $result;
     }
     return $results;
 }