0

I am trying to create a custom user query based on users' metadata. I have the following query created.

$users = new WP_User_Query( 
  array(  
    'search' => '*' . $search_name . '*',
    'meta_query' => array(
      'relation' => 'AND',
      array(
        'key' => 'Status',
        'value' => $search_status,
        'compare' => 'LIKE'
      ),
      array(
        'key' => 'Operation',
        'value' => $search_operation,
        'compare' => 'LIKE'
      ),
      array(
        'key' => 'visible_to_directory',
        'value' => '1',
        'compare' => '='
      )
    )
  )
);

When I have two custom meta values, it works great. Once I add more than that, it doesn't seem to work. Is this not supported with the WP_User_Query class?

1

I found that the answer was not found in my query, as it is correct. I was not passing variables to the query properly.

From my research, there is no constraint on the number of custom meta queries you can place in one query.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.