Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Ajax Search to respect visibility set by B2BKing › Reply To: Ajax Search to respect visibility set by B2BKing
April 6, 2022 at 9:00 am
#37435
Keymaster
That looks great, it will only work with the lite version, I made a change to apply for the Pro as well:
add_filter('asp_query_args', array($this, 'asp_query_args_postin'), 10, 1);
function asp_query_args_postin($args) {
$args['post_in'] = is_array($args['post_in']) ? $args['post_in'] : array();
if (!defined('ICL_LANGUAGE_NAME_EN')){
$allTheIDs = get_transient('b2bking_user_'.get_current_user_id().'_ajax_visibility');
} else {
$allTheIDs = get_transient('b2bking_user_'.get_current_user_id().'_ajax_visibility'.ICL_LANGUAGE_NAME_EN);
}
$allTheIDs = apply_filters('b2bking_ids_post_in_visibility', $allTheIDs);
$currentval = $args['post_in'];
if (!empty($currentval) && $allTheIDs !== false){
$allTheIDs = array_intersect($allTheIDs, $currentval);
}
if ($allTheIDs){
if(!empty($allTheIDs)){
$args['post_in'] = array_merge($args['post_in'], $allTheIDs);
}
}
return $args;
}