Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function find_lawyer( $country = '', $state = '', $city = '' ) {
- $meta_query = array(
- array(
- 'key' => 'user_locations',
- 'compare' => '!=',
- 'value' => ''
- ),
- array(
- 'key' => 'is_published',
- 'compare' => '=',
- 'value' => '1'
- ),
- );
- if ( $country ) {
- $meta_query[] = array(
- 'key' => 'user_locations',
- 'compare' => 'REGEXP',
- 'value' => '([\w|]*)country:' . $country . '([\w|]*)'
- );
- }
- if ( $state ) {
- $meta_query[] = array(
- 'key' => 'user_locations',
- 'compare' => 'REGEXP',
- 'value' => '([\w|]*)state:' . $state . '([\w|]*)'
- );
- }
- if ( $city ) {
- $meta_query[] = array(
- 'key' => 'user_locations',
- 'compare' => 'REGEXP',
- 'value' => '([\w|]*)city:' . $city . '([\w|]*)'
- );
- }
- $users_query = new WP_User_Query( array(
- 'role' => 'lawyer',
- 'meta_query' => $meta_query
- ) );
- return $users_query->get_results();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement