Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search displays hidden forums to participants

  • Hi,

    1) I created a hidden forum with topics and replies as a keymaster
    2) I logged in as a Participant
    3) A search will not display topics and replies as expected, but the forum itself is displayed!
    4) Clicking on the forum shows a 404 page, as expected

    bbPress 2.6.9

Viewing 9 replies - 1 through 9 (of 9 total)
  • Opened ticket for this topic: https://bbpress.trac.wordpress.org/ticket/3473


    Robin W
    Moderator

    @robin-w

    ok, so I followed your test.

    I created a forum called ‘test hidden forum’ and a topic within it called ‘test hidden topic’

    I logged in as a participant and did a search for ‘hidden’ – no results.

    What search were you doing that I could replicate?

    EDIT – sorry just looked at what you did in trac – I’ll try that


    Robin W
    Moderator

    @robin-w

    yes just tried ‘forum’ and it does not show

    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

    I did not see your answer. Sorry for that!

    I reinstalled a blank bbPress, with the same issue.

    You can see the hidden forum here with users keymaster/keymaster or participant/participant


    Robin W
    Moderator

    @robin-w

    1. can’t see as I don’t have access
    2. when you say ‘blank bbpress’ did you do the full tests above?

    1. You can connect with participant/participant or keymaster/keymaster here

    2. I should have said “plain” instead: WP + bbPress + 1 hidden forum + 1 public topen in forum


    Robin W
    Moderator

    @robin-w

    thanks – I can see the issue – suggest you change the keymaster pw to prevent this site being hacked

    I’ll now use my test site to see if I can work out what is happening

    Thanks.


    Robin W
    Moderator

    @robin-w

    ok, I’ve found the problem, and this filter fixes

    add_filter ('bbp_after_has_search_results_parse_args', 'rew_search') ;
    
    function rew_search ($args) {
    	/*mods and above get permissions to see all from line 50 of \bbpress\includes\search/template.php which sets a list of $default['post_status']
    	//participants/spectators get $default['perm'] = 'readable' set instead of $default['post_status'].  
    	'perm' is a wordpress wp_query setting, and wordpress does not have 'hidden' status, so allows hidden forums to show
    	//so if $default['perm'] is set, we add a 'post_status' as well to restrict to statuses user is allowed
    	*/
    	if (!empty($args['perm'])) {
    		$post_statuses = array(bbp_get_public_status_id()) ;
    		// Add support for private status
    		if ( current_user_can( 'read_private_topics' ) || current_user_can( 'read_private_forums' ) ) 
    			$post_statuses[] = bbp_get_private_status_id();
    		}
    		// Add support for hidden status
    		if ( current_user_can( 'read_hidden_forums' )) {
    			$post_statuses[] = bbp_get_hidden_status_id();
    		}
    		// Join post statuses together
    		$args['post_status'] = $post_statuses;
    	}
    return $args ;
    }

    if you are using

    bbp style pack


    then this is included in version 5.0.8 just released

    Otherwise 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

    I’ll update the bbpress trac ticket shortly

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