Skip to:
Content
Pages
Categories
Search
Top
Bottom

Private and Hidden sub-forum list visibility after posting topic


  • rinh
    Participant

    @rinh

    Greetings

    I set up a test forum and created a private category with two sub-forums inside. On forum index the category is shown with its two sub-forums listed below it, as intended.

    Once I post a topic in one of the sub-forums the list disappears below the category on forum index. I can still see them if I click on the category however.

    It’s similar to this bug here, but it doesn’t seem to matter if there’s a description or not
    https://bbpress.trac.wordpress.org/ticket/2085

    The bug only happen when the category is private or hidden. Should I do a bug report about it? Is there any known solutions?

    WordPress: 6.0
    Plugins: bbPress 2.6.9
    Theme: Tried various WordPress default themes.

    Thank you in advance

Viewing 9 replies - 1 through 9 (of 9 total)

  • Robin W
    Moderator

    @robin-w

    ok, I just created that test scenario, and cannot replicate

    Once I post a topic in one of the sub-forums the list disappears below the category on forum index.

    can you post a screenshot please so that I can understand exactly what is disappearing


    rinh
    Participant

    @rinh

    Here you go:

    Screenshot of forum index
    Screenshot 1

    Screenshot of forum index after I made a topic in Sub-Forum 1
    Screenshot 2


    Robin W
    Moderator

    @robin-w

    ok, my site after a post (and a sticky post also showing)

    http://www.rewweb.co.uk/wp-content/uploads/2019/07/Screenshot-2022-06-29-210816.png


    Robin W
    Moderator

    @robin-w

    it could be a theme or plugin issue

    Themes

    As a test switch to a default theme such as twentytwenty, and see if this fixes.

    Plugins

    If that doesn’t work, also deactivate all plugins apart from bbpress and see if this fixes. if it does, re-enable one at a time to see which is causing the error.

    If you cannot do this to your site (say because it is live) then use the ‘troubleshooting’ features of this plugin to let you test without affecting other users

    Health Check & Troubleshooting

    Then come back


    rinh
    Participant

    @rinh

    Thanks for checking into it.

    I only had bbPress installed and activated. I’ve switched to various themes including Twenty Twenty. I ran the Health and Troubleshooting, but everything seems fine. I also set up a local installation with the same result. There are no error logs either.

    Not sure what could cause it if it’s only happening to me. The issue does not happen if the category and sub-forums are public.


    Robin W
    Moderator

    @robin-w

    thanks, just tested with just bbpress and agree it does disappear.

    I had bbp private groups enabled, although no settings affecting, but with this it shows.

    I’ll try and take a look tomorrow (10pm in UK at the moment) to see what private groups does that is fixing that !


    rinh
    Participant

    @rinh

    Thank you a lot 🙂


    Robin W
    Moderator

    @robin-w

    ok, I’ve found time to take an initial look at this.

    The function called looks at a database item which holds the sub forum count – but it looks like this is just count of public forums, so the count is zero, so none displayed.

    so removing looking at this takes away the issue.

    It would take a deal of work to see why and how to make a permanent fix to this, and I think this filter will do what you want

    
    add_filter('bbp_forum_get_subforums', 'rew_forum_get_subforums', 10, 3);
    
    function rew_forum_get_subforums( $sub_forums, $r, $args ) {
    
    	// Default return value
    	$retval = array();
    	
    	// Use passed integer as post_parent
    	if ( is_numeric( $args ) && ! empty( $args ) ) {
    		$args = array( 'post_parent' => bbp_get_forum_id( $args ) );
    	}
    
    	// Parse arguments against default values
    	$r = bbp_parse_args( $args, array(
    		'post_parent'         => 0,
    		'post_type'           => bbp_get_forum_post_type(),
    		'posts_per_page'      => get_option( '_bbp_forums_per_page', 50 ),
    		'orderby'             => 'menu_order title',
    		'order'               => 'ASC',
    		'ignore_sticky_posts' => true,
    		'no_found_rows'       => true
    	), 'forum_get_subforums' );
    
    	// Ensure post_parent is properly set
    	$r['post_parent'] = bbp_get_forum_id( $r['post_parent'] );
    	
    	
    	// Query if post_parent has subforums
    	if ( ! empty( $r['post_parent'] )  ) {
    		$get_posts = new WP_Query();
    		$retval    = $get_posts->query( $r );
    	}
    	// Filter & return
    	return (array) apply_filters( 'rew_forum_get_subforums', $retval, $r, $args );
    	
    }

    Put this in your child theme’s function file –

    ie wp-content/themes/%your-theme-name%/functions.php

    where %your-theme-name% is the name of your theme

    or use

    Code Snippets


    rinh
    Participant

    @rinh

    Thanks for taking your time to look at this! Your filter works great and fixes the issue 🙂

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