Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › BuddyPress single Group search › Reply To: BuddyPress single Group search
October 8, 2020 at 2:26 pm
#29690
Keymaster
I’m sorry, my mistake. The corrected code is:
add_filter('asp_query_args', 'asp_restrict_by_bbp_groupx', 10, 1);
function asp_restrict_by_bbp_groupx($args) {
global $wpdb;
$group_ids = BP_Groups_Member::get_group_ids(get_current_user_id());
if ( is_array($group_ids['groups']) && count($group_ids['groups']) > 0 ) {
$args['buddypress_activities_query']['where'] = "AND ( " . $wpdb->prefix . "bp_activity.item_id IN(".implode(',', $group_ids['groups']).") )";
$args['buddypress_groups_query']['where'] = "AND ( " . $wpdb->prefix . "bp_groups.id IN(".implode(',', $group_ids['groups']).") )";
} else {
$args['buddypress_activities_query']['where'] = "AND ( " . $wpdb->prefix . "bp_activity.item_id = -1 )";
$args['buddypress_groups_query']['where'] = "AND ( " . $wpdb->prefix . "bp_groups.id = -1 )";
}
return $args;
}
I already placed it to the functions.php file, it should yield no errors now.