admin管理员组文章数量:1277373
I am creating a zip code radius search. I am pulling the all the zip codes within a radius depending on the search term through an API, then doing a user query to compare a custom meta field that has their zip and display those users if there is a match within the array of zip codes. I am doing this for both US/Canada. This is working except when I increase the radius and if that location happens to have a large amount of zip codes it breaks and no users are found. Especially in Canada there are literally thousands of zip code variations within just a 10km radius. For example if you look here .htm and search T5T 3E9 there are over 10k zip code results.
This only seems to be related to having a very large array. Any thoughts?
curl_setopt($ch, CURLOPT_URL, "?" .
http_build_query($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json",
"apikey: ", ));
$zipresponse = curl_exec($ch);
curl_close($ch);
$json = json_decode($zipresponse);
$resultArray = json_decode($zipresponse, true);
$zipCodd = $resultArray['results'];
$newzipArray = array();
if ( !empty( $zipCodd ) ) {
$i = 0;
foreach($zipCodd as $data){
$i++;
$newzipArray[$i] = str_replace(' ', '', $data['code']);
}
}
$user_search_args = array (
'number' => 50, // How many per users
'role' => 'subscriber',
's' => '*' . esc_attr( $search_term ) . '*',
'meta_query' => array(
'relation' => 'OR',
array(
'key' => array('mepr-address-zip', 'mepr_second_location_zip_2','mepr_third_location_zip_3'),
'value' => $newzipArray,
'compare' => 'IN'
),
)
);
$user_search_query = new WP_User_Query( $user_search_args );
本文标签: meta queryIssue with user metaquery
版权声明:本文标题:meta query - Issue with user meta_query 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741283389a2370135.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论