Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search form by forum ID

  • @dragoeco

    Participant

    Hi, I’m new with bbpress and using a WP (v4.7.3) with WPML (v3.6.6) to display 2 languages. I created 2 main forums named “English Forum” and “French Forum” with some sub forums under each of them, and I’m looking now for a way to display a search form to target only the “english forum” but also his child forum, and another which target the “french forum” with his child ones.

    I’ve found this :http://sevenspark.com/tutorials/how-to-search-a-single-forum-with-bbpress
    but it only search on a single forum ID (not to child ones).

    I googled for hours but, surprisingly, found nothing really helpful.

    I can create my own shortcode to display a search form but how to target a forum_id?

    Thanks for any help…

Viewing 4 replies - 1 through 4 (of 4 total)
  • @robin-w

    Moderator

    untested, and may need you to debug it a bit but something like changing step 3 to read

    /*
     * Search only a specific forum
     */
    function my_bbp_filter_search_results( $args ){
     
        //Get the submitted forum ID (from the hidden field added in step 2)
        $forum_id = sanitize_title_for_query( $_GET['bbp_search_forum_id'] );
    
    $sub_forums = bbp_forum_get_subforums( $forum_id );
    
     $args['post__in'] = $sub-forums ;
                
        
        return $args;
    }
    add_filter( 'bbp_before_has_search_results_parse_args' , 'my_bbp_filter_search_results' );
    

    you may need to add the main forum into the sub-forum list/

    @collizo4sky

    Participant

    I also needed something like this. Will try the code out.

    Thank you.

    @dragoeco

    Participant

    Hi Robin, and thanks a lot for your answer. I spent thours trying to achieve this but without success. The search just always returns results from all forums. I must confess I’m a beginner with PHP… But, is there any chance that this feature could be added in your “bbp additional shortcodes” plugin. Something like [bbp-search forums='10,12,15']. I just discovered your plugins on your website and you did an amazing work. Of course I’m ready to give some donation for that but I like to know if this is possible or not first 🙂 But maybe it’s not as simple… Thanks

    @robin-w

    Moderator

    thanks and glad it worked.

    my website is

    http://www.rewweb.co.uk

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Skip to toolbar