Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Searching private and hidden groups
- This topic has 26 replies, 2 voices, and was last updated 7 years, 3 months ago by
Sandy.
-
AuthorPosts
-
January 23, 2019 at 2:55 pm #20944
Sandy
ParticipantYou cannot access this content.
January 24, 2019 at 8:06 am #20954Ernest Marcinko
KeymasterYou cannot access this content.
January 24, 2019 at 9:37 am #20963Sandy
ParticipantYou cannot access this content.
January 24, 2019 at 3:43 pm #20967Ernest Marcinko
KeymasterHi,
Thank you, I may have found a possible solution, I am not sure. If you add the parent forum of that document to the filters list, it should be excluded now.
For future reference, I have constructed the following code into the functions.php file in your child theme directory:
// -- AJAX SEARCH PRO SPECIFIC -- add_filter('asp_results', 'asp_results_filter_attachments', 10, 4); function asp_results_filter_attachments($results, $id, $is_ajax, $args) { if ( isset($args['post_meta_filter']) ) { $ids = array(); foreach ( $args['post_meta_filter'] as $pm ) { if ( $pm['key'] == '_bbp_forum_id' ) $ids[] = $pm['value']; } if (count($ids) > 0) { foreach ($results as $k => &$r) { if (isset($r->post_type) && $r->post_type == 'attachment') { $pid = wp_get_post_parent_id( $r->id ); $forum_id = (int)get_post_meta($pid, '_bbp_forum_id', true); while ( !empty($forum_id) ) { if ( in_array($forum_id, $ids) ) { unset($results[$k]); break; } $forum_id = wp_get_post_parent_id( $forum_id ); } } } } } return $results; }January 24, 2019 at 4:30 pm #20970Sandy
ParticipantHi,
Do you mean i should make an exclude rule to each search for each forum which has attachements?
This site is going to have many different forums not sure if that’s manageable, or did you mean something else?Best,
-SandyJanuary 25, 2019 at 9:26 am #20974Ernest Marcinko
KeymasterHi,
Isn’t that what you need? I thought you want to hide attachments from specific forums.
If you simply don’t want any attachments, you can turn off the attachments search.January 25, 2019 at 9:30 am #20975Sandy
ParticipantGood morning Ernest,
i do want to show Attachements in the search, so if i have 20 forums all with attachments should i make 19 exclude rules for each dedicated search?
Best,
-SandyJanuary 25, 2019 at 10:13 am #20976Ernest Marcinko
KeymasterHi Sandy,
It might be the only solution. Unfortunately there is no direct connection between the forum and the attachment, only the topic/reply and the attachment.
I could somehow modify the code so that for each search instace there is only a number of allowed forums for attachments, in that case you wouldn’t need those rules for the attachments.
If you can make a list of which search ID should display attachments from which forum IDs only, let me know. I will try to add that to the code.January 30, 2019 at 1:50 pm #21035Sandy
ParticipantYou cannot access this content.
February 5, 2019 at 12:28 pm #21046Sandy
ParticipantHi Ernest,
Hope you have some time to look into this.
Thanks,
-SandyFebruary 11, 2019 at 1:01 pm #21052Ernest Marcinko
KeymasterHi Sandy,
Sorry for the late response, we were on a short family vacation.
I believe the custom code I did there is causing the problem, as it is explicitly made for exclusions, but not inclusions, it won’t work that way. Can you please try without using the custom code?
February 12, 2019 at 10:11 am #21071Sandy
ParticipantHi Ernest,
Hope you had a great holiday!
In the end i removed the subforums, so now it’s working,
but in the feature i will need this to work.Best,
-Sandy -
AuthorPosts
- You must be logged in to reply to this topic.