Title: Search Multiple Fields
Last modified: November 15, 2017

---

# Search Multiple Fields

 *  [juiceex](https://wordpress.org/support/users/juiceex/)
 * (@juiceex)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/search-multiple-fields/)
 * So I’ve added the following code to my functions.php which limits the search 
   bar to ONLY look at last_name. But I’d like to expand it to include **first_name**
   and **phone_number**. How do I let the search bar cover those additional fields?
 *     ```
       function kia_meta_search( $args ){
   
         // this $_GET is the name field of the custom input in search-author.php
           $search = ( isset($_GET['as']) ) ? sanitize_text_field($_GET['as']) : false ;
   
           if ( $search ){
               // if your shortcode has a 'role' parameter defined it will be maintained
               // unless you choose to unset the role parameter by uncommenting the following
               //  unset( $args['role'] );
               $args['meta_key'] = 'last_name';
               $args['meta_value'] = $search;
               $args['meta_compare'] = '=';
   
               // need to unset the original search args
               if( isset( $args['search'] ) ) unset($args['search']);
           }
   
           return $args;
       }
       add_filter('sul_user_query_args', 'kia_meta_search');
       ```
   

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [juiceex](https://wordpress.org/support/users/juiceex/)
 * (@juiceex)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/search-multiple-fields/#post-9686424)
 * By the way “phone_number” is an Advanced Custom Field I’ve added to users… incase
   that matters.
 *  Plugin Author [HelgaTheViking](https://wordpress.org/support/users/helgatheviking/)
 * (@helgatheviking)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/search-multiple-fields/#post-9687777)
 * See the “Multiple custom user fields handling” section of the [codex for `WP_User_Query`](https://codex.wordpress.org/Class_Reference/WP_User_Query#Custom_Field_Parameters).
   So it’s possble to do with `WP_User_Query`. But while that is the basis for Simple
   User Listing, SUL can’t quite support that, so you will need to filter the query
   args and pass a complex meta query. See “How to create very complex user queries
   | How to query multiple meta keys” section in the [FAQ](https://wordpress.org/plugins/simple-user-listing/#faq).

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Search Multiple Fields’ is closed to new replies.

 * ![](https://ps.w.org/simple-user-listing/assets/icon-256x256.png?rev=3061308)
 * [Simple User Listing](https://wordpress.org/plugins/simple-user-listing/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/simple-user-listing/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/simple-user-listing/)
 * [Active Topics](https://wordpress.org/support/plugin/simple-user-listing/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/simple-user-listing/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/simple-user-listing/reviews/)

## Tags

 * [ACF](https://wordpress.org/support/topic-tag/acf/)

 * 2 replies
 * 2 participants
 * Last reply from: [HelgaTheViking](https://wordpress.org/support/users/helgatheviking/)
 * Last activity: [8 years, 6 months ago](https://wordpress.org/support/topic/search-multiple-fields/#post-9687777)
 * Status: not resolved