bp_core_redirect

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

Description

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

Parameters (2)

0. $location — Optional. (string) => ''
The redirect URL.
1. $status — Optional. (int) => 302
The numeric code to give in the redirect headers. Default: 302.

Usage

  1. if ( !function_exists( 'bp_core_redirect' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-core/bp-core-functions.php'; 
  3.  
  4. // The redirect URL. 
  5. $location = ''; 
  6.  
  7. // Optional. The numeric code to give in the redirect 
  8. // headers. Default: 302. 
  9. $status = 302; 
  10.  
  11. // NOTICE! Understand what this does before running. 
  12. $result = bp_core_redirect($location, $status); 
  13.  

Defined (1)

The function is defined in the following location(s).

/bp-core/bp-core-functions.php  
  1. function bp_core_redirect( $location = '', $status = 302 ) { 
  2.  
  3. // On some setups, passing the value of wp_get_referer() may result in an 
  4. // empty value for $location, which results in an error. Ensure that we 
  5. // have a valid URL. 
  6. if ( empty( $location ) ) { 
  7. $location = bp_get_root_domain(); 
  8.  
  9. // Make sure we don't call status_header() in bp_core_do_catch_uri() as this 
  10. // conflicts with wp_redirect() and wp_safe_redirect(). 
  11. buddypress)->no_status_set = true; 
  12.  
  13. wp_safe_redirect( $location, $status ); 
  14. die;