Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Groups and hide products › Reply To: Groups and hide products
February 20, 2019 at 2:37 pm
#21202
Keymaster
Hi,
Thank you very much!
I think I managed to find a solution based on the plugin API. The category based exclusions seem to have a different API, so the code needs to be extended. The final solution is:
add_filter('asp_results', 'asp_fix_groups_exclusions', 10, 1);
function asp_fix_groups_exclusions($results) {
// Group based exclusions
if ( class_exists('Groups_Post_Access') ) {
foreach ($results as $k => &$r) {
if ( isset($r->post_type) && !Groups_Post_Access::user_can_read_post($r->id) )
unset($results[$k]);
}
}
// Category based exclusions
if ( class_exists('Groups_Restrict_Categories') ) {
foreach ($results as $k => &$r) {
if ( isset($r->post_type) && !Groups_Restrict_Categories::user_can_read($r->id) )
unset($results[$k]);
}
}
return $results;
}
Please check if this is correct. Thanks!