if ( is_bbpress() && !is_user_logged_in() ) {
wp_redirect( 'https://www.xy.com/intranet'); // if this redirects to your login page
}
And this is your login form:
$args = array(
'echo' => true,
'redirect' => site_url( $_SERVER['REQUEST_URI'] ), // this will redirect
'form_id' => 'loginform',
'label_username' => __( 'Username' ),
'label_password' => __( 'Password' ),
'label_remember' => __( 'Remember Me' ),
'label_log_in' => __( 'Log In' ),
'id_username' => 'user_login',
'id_password' => 'user_pass',
'id_remember' => 'rememberme',
'id_submit' => 'wp-submit',
'remember' => true,
'value_username' => NULL,
'value_remember' => false );
wp_login_form( $args );
So what happens above us this:
- If you are on BB and you are not logged in, your will be redirected to the login page
- And once you are logged in, you will return to the previous page
I haven't tested the script, but it is logically correct.