BuddyPress single Group search

Home Forums Product Support Forums Ajax Search Pro for WordPress Support BuddyPress single Group search

This topic contains 20 replies, has 2 voices, and was last updated by aspectavenue65 aspectavenue65 3 years, 5 months ago.

Viewing 15 posts - 1 through 15 (of 21 total)
  • Author
    Posts
  • #29619
    aspectavenue65
    aspectavenue65
    Participant

    Hi,

    I don’t have a technical problem, I just think it might not do what I thought it would…and wonder if you can help, or offer a refund if I was mistaken?

    From the screenshots at CodeCanyon, a thought Ajax Search Pro would help me to create a search for posts within single specific BuddyPress Groups. That’s the main reason I bought it at the weekend.

    I’ve set up a search, with the BuddyPress options toggled on, but there doesn’t seem to be a way to have a search for individual BuddyPress Groups – only All Groups.

    If I’ve made a mistake, and Ajax Search Pro can’t create a search for individual Groups, could you issue a refund please?

    Thank you,
    Victor Taylor.

    #29629
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    Well, there isn’t an option to do that unfortunately. There might be a programattical solution though. Can you please add temporary FTP and back-end access? Also, please let me know which group(s) you want to restrict the activity results to.
    I will try to programmatically implement a quick solution via FTP and if it works, then append it to the upcoming release.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #29659
    aspectavenue65
    aspectavenue65
    Participant

    Hi Ernest,

    Thank you.

    I can give access, but it sounds like this would be a one-off fix – for existing BP groups, but not for future groups later created by members?

    Also I didn’t mention, but with BP settings on, I tried a front end search but there were no results when searching for a word/sentence that was actually in a Group post on the same page as the search form…!

    I acknowledge that is a really great software, which is obvious from the many 5-star reviews from happy customers – but I think it might all be too complicated for me to spend time on at this early, pre-launch stage of the website…

    Let me know if it’s an easy thing for you to sort out for me (including it working for future new groups) and I’ll set up access logins for you.
    Otherwise, I’m fine with just a refund for now – and maybe buy again at a future date when my site is more established.

    Thanks a lot.

    #29664
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    Well, it is more of a programmatical solution – so existing group IDs had to be added afterwards.

    Also I didn’t mention, but with BP settings on, I tried a front end search but there were no results when searching for a word/sentence that was actually in a Group post on the same page as the search form…!
    I would have to check the exact scenario of this to be able to tell what might be wrong.

    You can apply for a refund of course, here: http://codecanyon.net/refund_requests/new
    There is a chance that it might get rejected, as we need to follow our seller refund policy: https://codecanyon.net/page/customer_refund_policy

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #29668
    aspectavenue65
    aspectavenue65
    Participant
    You cannot access this content.
    #29679
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    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.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #29680
    aspectavenue65
    aspectavenue65
    Participant

    Thank you…

    You misunderstood though – or I wasn’t clear enough.
    I’d like users to be able to search just within the group they are using/viewing.

    Example:

    – Someone is viewing/browsing the ‘Business Q&As’ group…

    – The search form displayed in the ‘Business Q&As’ group is a search form just for the ‘Business Q&As’ group.
    (Each Group has its own dedicated search form.)

    – The user wants to search for answers or something, only in the ‘Business Q&As’ group.
    So he/she does a search, and gets results only from the ‘Business Q&As’ group.

    Is that a big job to do?
    If it is too much of a big job, I will be OK for users to just be able to search ALL groups in the way you have set it up for me.

    Thanks.

    #29685
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    I’m afraid I cannot do that, I could not find all the functions I would need for that in the buddypress API. I’m sure it is doable though, but it requires a bit more work for sure.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #29689
    aspectavenue65
    aspectavenue65
    Participant

    OK understood, thanks.
    I’ll just have a ‘search all groups’ for now.

    I added the code to functions.php but it caused a critical error on the site.
    “There has been a critical error on your website.”
    So I’ve had to remove the code.

    If you can take a look, I’ve changed the FTP access to /wp-content/themes/ for you to access functions.php in the child theme: generatepress-child

    Many thanks for your time and patience!

    #29690
    Ernest Marcinko
    Ernest Marcinko
    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.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #29695
    aspectavenue65
    aspectavenue65
    Participant

    Thank you 🙂

    Just one more problem…

    As mentioned, no search results are showing for Groups activity content.

    I have set things up properly as far as I can tell in WP (you still have access if you want to look…)
    But there are no search results from Group posts – even for text that definitely exists.

    (Search results are perfect for normal pages and posts.)

    #29696
    aspectavenue65
    aspectavenue65
    Participant

    PS… Is it possible to Exclude certain pages/posts from results? Thanks.

    #29710
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    There is a content type fitler enabled: https://i.imgur.com/9TGgklb.png
    That completely excludes all buddypress groups and activities from results. Make sure to remove that.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #29716
    aspectavenue65
    aspectavenue65
    Participant

    I see. Brilliant, thank you 🙂

    Thanks for all your help this week, I’m beginning to see just how amazing your software is!

    Have a nice weekend.

    #29717
    Ernest Marcinko
    Ernest Marcinko
    Keymaster
    You cannot access this content. Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 15 posts - 1 through 15 (of 21 total)

You must be logged in to reply to this topic.