bp_login_redirector()
Login redirector.
Description
If a link is not publicly available, we can send members from external locations, like following links in an email, through the login screen.
If a user clicks on this link and is already logged in, we should attempt to redirect the user to the authorized content instead of forcing the user to re-authenticate.
Source
File: bp-core/bp-core-catchuri.php
function bp_login_redirector() { // Redirect links must include the `redirect_to` and `bp-auth` parameters. if ( empty( $_GET['redirect_to'] ) || empty( $_GET['bp-auth'] ) ) { return; } /* * If the user is already logged in, * skip the login form and redirect them to the content. */ if ( bp_loggedin_user_id() ) { wp_safe_redirect( esc_url_raw( $_GET['redirect_to'] ) ); exit; } }
Changelog
Version | Description |
---|---|
BuddyPress 2.9.0 | 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.