php – WordPress WP_User_Query() combine query-ThrowExceptions

Exception or error:

How to combine wordpress user query look like this example from another question WordPress combine queries
this question have answer for this it use WP_Combine_Queries class for realizing but this answer only for posts and this not work for users query

$args1 = array(
    'role'   => 'specialist',
    'meta_key'  => 'profession',
    'meta_value' => $term->ID,
    'meta_query' => array(
          array(
              'key' => 'be_first',
              'compare' => 'EXISTS',
          ),
          array(
              'key' => 'pro_date',
              'value' => current_time('timestamp'),
              'compare' => '>'
          )
      ),
    'orderby'    => 'be_first',
    'order'      => 'DESC',
    'number'   => 0,
    'fields'  =>'ID',
    'count_total' => true,
  );

$args2 = array(
    'role'   => 'specialist',
    'meta_key'  => 'profession',
    'meta_value' =>$term->ID,
    'meta_query' => array(
          array(
              'key' => 'pro_date',
              'value' => current_time('timestamp'),
              'compare' => '>'
          )
      ),
    'orderby'             => 'pro_date',
    'order'               => 'DESC',
    'number'   => 0,
    'count_total'         => true,
  );
$args3 = array(
    'role'   => 'specialist',
    'meta_key'  => 'profession',
    'meta_value' =>$term->ID,
    'orderby'    => 'like',
    'order'      => 'DESC',
    // 'offset'   => $offset,
    // 'number'   => $number,
    // 'paged'    => $paged,
    'count_total' => true,
  );

$args = array( 
   'number' => $number,
   'paged'          => $paged,
   'offset' =>$offset
   'sublimit'       => 1000,
   'args'           => array( $args1, $args2, $args3),
);

$results = new WP_Combine_Queries( $args );
How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *