bbp_logged_in_redirect( string $url = '' )

Redirect a user back to their profile if they are already logged in.


Description 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 Parameters

$url

(Optional) The URL to redirect to

Default value: ''


Top ↑

Source Source

File: includes/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
	bbp_redirect( $redirect_to );
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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