bbp_logged_in_redirect( string $url = '' )
Redirect a user back to their profile if they are already logged in.
Description
This should be used before get_header() is called in template files where the user should never have access to the contents of that file.
Parameters
- $url
-
(Optional) The URL to redirect to
Default value: ''
Source
File: bp-forums/users/template.php
function bbp_logged_in_redirect( $url = '' ) { // Bail if user is not logged in if ( !is_user_logged_in() ) return; // Setup the profile page to redirect to $redirect_to = !empty( $url ) ? $url : bbp_get_user_profile_url( bbp_get_current_user_id() ); // Do a safe redirect and exit wp_safe_redirect( $redirect_to ); exit; }
Changelog
Version | Description |
---|---|
bbPress (r2815) | 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.