bp_login_redirector()

Login redirector.


Description 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 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;
	}
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.9.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.