bp_core_redirect( string $location = '', int $status = 302 )

Perform a status-safe wp_redirect() that is compatible with BP’s URI parser.

Description

Parameters

$location

(string) (Optional) The redirect URL.

Default value: ''

$status

(int) (Optional) The numeric code to give in the redirect headers. Default: 302.

Default value: 302

Source

File: bp-core/bp-core-functions.php

function bp_core_redirect( $location = '', $status = 302 ) {

	// On some setups, passing the value of wp_get_referer() may result in an
	// empty value for $location, which results in an error. Ensure that we
	// have a valid URL.
	if ( empty( $location ) ) {
		$location = bp_get_root_domain();
	}

	// Make sure we don't call status_header() in bp_core_do_catch_uri() as this
	// conflicts with wp_redirect() and wp_safe_redirect().
	buddypress()->no_status_set = true;

	wp_safe_redirect( $location, $status );

	// If PHPUnit is running, do not kill execution.
	if ( ! defined( 'BP_TESTS_DIR' ) ) {
		die;
	}
}

Changelog

Changelog
Version Description
BuddyPress 1.0.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.