If you want to restrict access to bbPress forums for only logged-in users, use this snippet:
function restrict_bbpress_access() {
if ( is_bbpress() && !is_user_logged_in() ) {
wp_redirect( home_url() );
exit;
}
}
add_action( 'template_redirect', 'restrict_bbpress_access' );
This will redirect visitors to the homepage if they are not logged in.