Title: get_users meta_query with multiple custom fields
Last modified: August 21, 2016

---

# get_users meta_query with multiple custom fields

 *  [matic_a](https://wordpress.org/support/users/matic_a/)
 * (@matic_a)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/get_users-meta_query-with-multiple-custom-fields/)
 * Hello
    I am working on one filed user search. Basicly I need one field (like 
   default WordPress search) that will search in users for that search string.
 * I have made a few custom fields:
    city (string) country (drop-down list of pre-
   defined countries) user_description (I have removed default”bio” textarea and
   made new one.) telephone mobile phone
 * So I would like to search in these custom fields for provided search string.
   
   I was working on meta_query but either I get a list of all users or none so ever.
 * I was working on this code:
 *     ```
       $search_word = "eng";
           $args = array(
       		'role' => 'contributor',
               'meta_query'   => array(
                       'relation' => 'OR',
   
                   array(
                       'key' => 'country',
                       'value' => $search_word,
                       'compare' => 'LIKE'
                   ),
                   array(
                       'key' => 'city',
                       'value' =>  $search_word,
                       'compare' => 'LIKE'
                   )
   
              )
           );
       $users = get_users($args);
       foreach($users as $user) {
       if ( $user->city ) { echo $user->city; };
       }
       ```
   
 * So I need to search in multiple custom fields where in ANY of these fields has
   a value LIKE the search string.
 * **Can someone give me a hint what I did wrong?**
 * And another question:
    **Can I “order” the results by custom field or only on
   default fields?**
 * Thank you all for your help.
 * Regards
    Matic

The topic ‘get_users meta_query with multiple custom fields’ is closed to new replies.

## Tags

 * [get_users](https://wordpress.org/support/topic-tag/get_users/)
 * [meta_query](https://wordpress.org/support/topic-tag/meta_query/)
 * [user search](https://wordpress.org/support/topic-tag/user-search/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [matic_a](https://wordpress.org/support/users/matic_a/)
 * Last activity: [12 years, 11 months ago](https://wordpress.org/support/topic/get_users-meta_query-with-multiple-custom-fields/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
