I am creating a custom plugins which has the ability to search users according to their meta values. Everything is perfect except the part when the checkbox query is checked. If i check the checkbox the query returns 3 same results. The search is working fine as I am getting the desired result but 3 times. Here is my code tried so far.
$users = new WP_User_Query( array(
'search' => "*{$pem}*",
'search_columns' => array(
'user_email',
),
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'first_name',
'value' => $fname,
'compare' => '='
),
array(
'key' => 'last_name',
'value' => $lname,
'compare' => '='
),
array(
'key' => 'min_salary',
'value' => $salary_min,
'compare' => '='
),
array(
'key' => 'empl',
'value' => $status,
'compare' => '='
),
array(
'key' => 'min_hrly',
'value' => $salary_hourly,
'compare' => '='
),
array(
'key' => 'years_work',
'value' => $years_work,
'compare' => '='
),
array(
'key' => 'years_non',
'value' => $years_non,
'compare' => '='
),
array(
'key' => 'expert_work',
'value' => $expert_work,
'compare' => '='
),
array(
'key' => 'a_city',
'value' => $addr['city'],
'compare' => '='
),
array(
'key' => 'a_state',
'value' => $addr['stt'],
'compare' => '='
),
array(
'key' => 'a_zip',
'value' => $addr['zip'],
'compare' => '='
),array(
'key' => 'startday',
'value' => $startdate['day'],
'compare' => '='
),
array(
'key' => 'startmonth',
'value' => $startdate['month'],
'compare' => '='
),
array(
'key' => 'startyear',
'value' => $startdate['year'],
'compare' => '='
),
array(
'key' => 'hdeg',
'value' => $education,
'compare' => '='
),
array(
'key' => 'sekj',
'value' => $position1,
'compare' => '='
),
array(
'key' => 'seekk',
'value' => $position2,
'compare' => '='
),
array(
'key' => 'checkbox',
'value' => $expert['a'],
'compare' => 'LIKE'
),
)
) );
$users_found = $users->get_results();
This problem only arise when I add query for checkbox else everything is working good.
Am I missing something?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire