Title: WP_User_Query and conditional checkbox array
Last modified: August 22, 2016

---

# WP_User_Query and conditional checkbox array

 *  Resolved [newward](https://wordpress.org/support/users/newward/)
 * (@newward)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/wp_user_query-and-conditional-checkbox-array/)
 * I am in the process of creating a user search form and would like to have the
   users have the ability to search for multiple check box conditions.
 * Here is what I currently have for the checkbox on the form
 *     ```
       <input type="checkbox" class="textbox" name="services[]" id="services" value="ministryPlanning" /> Ministry Planning <br />
       	<input name="services[]" type="checkbox" id="services" value="visionAnalysis" /> Vision Analysis <br />
       	<input name="services[]" type="checkbox" id="services" value="buildingCommittee" /> Forming Planning/Building Committee <br />
       	<input name="services[]" type="checkbox" id="services" value="selectionConsultants" /> Selection of Other Consultants <br />
       	<input name="services[]" type="checkbox" id="services" value="educationProcess" /> Include Liturgical Education Process <br />
       	<input name="services[]" type="checkbox" id="services" value="largeGroup" /> Large Group Facilitation <br />
       	<input name="services[]" type="checkbox" id="services" value="smallGroup" /> Small Group Facilitation <br />
       	<input name="services[]" type="checkbox" id="services" value="spaceProgramming" /> Liturgical Space Programming <br />
       	<input name="services[]" type="checkbox" id="services" value="artConsulting" /> Liturgical Art Consulting <br />
       	<input name="services[]" type="checkbox" id="services" value="designsFunishing" /> Designs Liturgical Furnishings <br />
       	<input name="services[]" type="checkbox" id="services" value="furshinhingConsulting" /> Liturgical Furnishings Consulting <br />
       	<input name="services[]" type="checkbox" id="services" value="sacredArt" /> Designs/Fabricates/Installs Sacred Art or Furnishings <br />
       	<input name="services[]" type="checkbox" id="services" value="ritualPlanning" /> Ritual Planning <br />
       	<input name="services[]" type="checkbox" id="services" value="trainingMinisters" /> Training for Liturgical Ministers';
       ```
   
 * and here is the form processing
 *     ```
       if(!empty($_GET['services'])) {
       		$arr =	array('relation' => 'OR');
       		$i = 0;
       		foreach($_GET['services'] as $service) {
       				$arr[$i] =  array(
       						'key'     => 'services',
       						'value'   => $service,
       						'compare' => 'LIKE'
       					);
       			$i = $i + 1;
           	}
       	$the_user_query =  array('meta_query' => array($arr));
   
       	}
       $the_users = new WP_User_Query( $the_user_query );
       ```
   
 * When I display the users that were selected it is always giving me back all of
   the users. But if I change the code to and hard code the selection it works.
 *     ```
       $the_user_query = array(
       			'meta_query' => array(
       				'relation' => 'OR',
       				0 => array(
       					'key'     => 'services',
       					'value'   => 'ministryPlanning',
       					'compare' => 'LIKE'
       				),
       				1 => array(
       					'key'     => 'services',
       					'value'   => 'visionAnalysis',
       					'compare' => 'LIKE'
       				)
       			)
       		 );
       ```
   
 * I am not sure what is different between the 2.
 * Here is the page for this site
    [http://liturgical-consultants.org/wp/find-a-member/](http://liturgical-consultants.org/wp/find-a-member/)

Viewing 1 replies (of 1 total)

 *  Thread Starter [newward](https://wordpress.org/support/users/newward/)
 * (@newward)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/wp_user_query-and-conditional-checkbox-array/#post-5391314)
 * OK I figured it out.
 * I had too many arrays within $the_user_query
 * This statement
    $the_user_query = array(‘meta_query’ => array($arr));
 * just needed to be
    $the_user_query = array(‘meta_query’ => $arr);
 * $arr didn’t need to be defined as an array again.
 * Hope this help someone else someday.

Viewing 1 replies (of 1 total)

The topic ‘WP_User_Query and conditional checkbox array’ is closed to new replies.

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 1 reply
 * 1 participant
 * Last reply from: [newward](https://wordpress.org/support/users/newward/)
 * Last activity: [11 years, 7 months ago](https://wordpress.org/support/topic/wp_user_query-and-conditional-checkbox-array/#post-5391314)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
