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

(Optional) The redirect URL.

Default value: ''

$status

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

Default value: 302

Source

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

1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
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.