Searching private and hidden groups

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Searching private and hidden groups

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

Viewing 12 posts - 16 through 27 (of 27 total)
  • Author
    Posts
  • #20944
    Sandy
    Sandy
    Participant
    You cannot access this content.
    #20954
    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 :)


    #20963
    Sandy
    Sandy
    Participant
    You cannot access this content.
    #20967
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    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;
    }
    Best,
    Ernest Marcinko

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


    #20970
    Sandy
    Sandy
    Participant

    Hi,
    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,
    -Sandy

    #20974
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    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.

    Best,
    Ernest Marcinko

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


    #20975
    Sandy
    Sandy
    Participant

    Good 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,
    -Sandy

    #20976
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi 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.

    Best,
    Ernest Marcinko

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


    #21035
    Sandy
    Sandy
    Participant
    You cannot access this content.
    #21046
    Sandy
    Sandy
    Participant

    Hi Ernest,

    Hope you have some time to look into this.

    Thanks,
    -Sandy

    #21052
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi 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?

    Best,
    Ernest Marcinko

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


    #21071
    Sandy
    Sandy
    Participant

    Hi 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

Viewing 12 posts - 16 through 27 (of 27 total)

You must be logged in to reply to this topic.