Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › BuddyPress single Group search › Reply To: BuddyPress single Group search
Thank you for the details.
I think I understand your request now – you want to display results (both activities and groups) associated to groups where the user is actually a member. Is that correct?
I made a modification to the plugin core code to allow another custom code application. I will add this modification to the future plugin update as well.
Now, please add this custom code to the functions.php in your theme/child theme directory. Before editing, please make sure to have a full site back-up just in case!
add_filter('asp_query_args', 'asp_restrict_by_bbp_group', 10, 1);
function asp_restrict_by_bbp_group($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;
}
This code will actually add query restrictions to show results from associated groups for each user. It includes any future groups as well, as it always requests the groups for the currently logged in user as well.
I would have already added this for you, but the FTP access was restricted to the search plugin folder only.