Opened 3 years ago
Closed 9 months ago
#3473 closed defect (bug) (fixed)
Search displays hidden forums to participants
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 2.6.10 | Priority: | high |
Severity: | normal | Version: | 2.6.9 |
Component: | Component - Search | Keywords: | needs-patch |
Cc: |
Description
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
WordPress 6.0
Plugins active: bbPress, Classic Editor
Attachments (6)
Change History (11)
#1
@
3 years ago
- Keywords needs-patch added
- Milestone changed from Awaiting Review to 2.6.10
- Owner set to johnjamesjacoby
- Priority changed from normal to high
- Status changed from new to assigned
#2
@
3 years ago
I could not replicate this in my test site.
User has not responded further in support topic
https://bbpress.org/forums/topic/search-displays-hidden-forums-to-participants/
#3
@
3 years ago
correction, I've now replicated
the issue is in \bbpress\includes\search\template.php line 49 onwards
mods and above get permissions to see all from line 50 which sets a list of $defaultpost_status?
participants/spectators get $defaultperm? = 'readable' set instead of $defaultpost_status?.
'perm' is a wordpress wp_query setting, and wordpress does not have 'hidden' status, so allows hidden forums to show, nit sure why, but it does !
if the 'else' line is revised to set permissions, then all works as it should
this filter fixes
add_filter ('bbp_after_has_search_results_parse_args', 'bsp_search_hide_hidden_forums') ; <?php function bsp_search_hide_hidden_forums ($args) { if (!empty($args['perm'])) { unset ($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 ; }
#4
@
9 months ago
This is a fun one, because it is a combination of bugs!
- "Hidden" forum IDs are being excluded via a
meta_query
throughbbp_pre_get_posts_normalize_forum_visibility()
, but that doesn't work on the forums themselves because they don't store their own forum ID in their own meta data. - "Private" forum IDs are only being made visible to: Key Masters, or the authors of the private forums.
I have a fix for both incoming.
Capture of search showing a hidden forum to a particpant