bbp_forum_enforce_private()
Check if it’s a private forum or a topic or reply of a private forum and if the user can’t view it, then sets a 404
Description Description
Source Source
File: includes/forums/functions.php
function bbp_forum_enforce_private() { // Bail if not viewing a single item or if user has caps if ( ! is_singular() || bbp_is_user_keymaster() || current_user_can( 'read_private_forums' ) ) { return; } // Define local variables $forum_id = 0; $wp_query = bbp_get_wp_query(); // Check post type switch ( $wp_query->get( 'post_type' ) ) { // Forum case bbp_get_forum_post_type() : $forum_id = bbp_get_forum_id( $wp_query->post->ID ); break; // Topic case bbp_get_topic_post_type() : $forum_id = bbp_get_topic_forum_id( $wp_query->post->ID ); break; // Reply case bbp_get_reply_post_type() : $forum_id = bbp_get_reply_forum_id( $wp_query->post->ID ); break; } // If forum is explicitly hidden and user not capable, set 404 if ( ! empty( $forum_id ) && bbp_is_forum_private( $forum_id ) && ! current_user_can( 'read_forum', $forum_id ) ) { bbp_set_404( $wp_query ); } }
Changelog Changelog
Version | Description |
---|---|
2.0.0 | Introduced. |