bbp_user_can_view_forum( $args = '' )
Check if the user can access a specific forum
Description
Return
(bool)
Source
File: bp-forums/users/template.php
function bbp_user_can_view_forum( $args = '' ) { // Parse arguments against default values $r = bbp_parse_args( $args, array( 'user_id' => bbp_get_current_user_id(), 'forum_id' => bbp_get_forum_id(), 'check_ancestors' => false ), 'user_can_view_forum' ); // Validate parsed values $user_id = bbp_get_user_id( $r['user_id'], false, false ); $forum_id = bbp_get_forum_id( $r['forum_id'] ); $retval = false; // User is a keymaster if ( !empty( $user_id ) && bbp_is_user_keymaster( $user_id ) ) { $retval = true; // Forum is public, and user can read forums or is not logged in } elseif ( bbp_is_forum_public( $forum_id, $r['check_ancestors'] ) ) { $retval = true; // Forum is private, and user can see it } elseif ( bbp_is_forum_private( $forum_id, $r['check_ancestors'] ) && user_can( $user_id, 'read_private_forums' ) ) { $retval = true; // Forum is hidden, and user can see it } elseif ( bbp_is_forum_hidden ( $forum_id, $r['check_ancestors'] ) && user_can( $user_id, 'read_hidden_forums' ) ) { $retval = true; } return apply_filters( 'bbp_user_can_view_forum', $retval, $forum_id, $user_id ); }
Changelog
Version | Description |
---|---|
bbPress (r3127) | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.