1

I have a search engine where I can search for users on the front end. Profiles have mulitple custom fields. I'm just searching first and last name in this example. The problem is I can search for a last or first name, but not both combined...

 $my_users = new WP_User_Query( 
      array( 
        'meta_query' => array(
            'relation' => 'OR',
                array(
                    'key' => 'first_name',
                    'value' => $search,
                    'compare' => 'LIKE',
                ), 
                array(
                    'key' => 'last_name',
                    'value' => $search,
                    'compare' => 'LIKE',
                ), 
            )
      ));

Your Answer

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

Browse other questions tagged or ask your own question.