wp_redirect

Redirects to another page.

Description

wp_redirect( (string) $location, (int) $status = 302 ); 

Parameters (2)

0. $location (string)
The path to redirect to
1. $status — Optional. (int) => 302
Status code to use

Usage

  1. if ( !function_exists( 'wp_redirect' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-includes/functions.bb-pluggable.php'; 
  3.  
  4. // The path to redirect to 
  5. $location = ''; 
  6.  
  7. // Status code to use 
  8. $status = 302; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wp_redirect($location, $status); 
  12.  

Defined (1)

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

/bp-forums/bbpress/bb-includes/functions.bb-pluggable.php  
  1. function wp_redirect($location, $status = 302) { 
  2. global $is_IIS; 
  3.  
  4. $location = apply_filters('wp_redirect', $location, $status); 
  5. $status = apply_filters('wp_redirect_status', $status, $location); 
  6.  
  7. if ( !$location ) // allows the wp_redirect filter to cancel a redirect 
  8. return false; 
  9.  
  10. $location = wp_sanitize_redirect($location); 
  11.  
  12. if ( $is_IIS ) { 
  13. header("Refresh: 0;url=$location"); 
  14. } else { 
  15. if ( php_sapi_name() != 'cgi-fcgi' ) 
  16. status_header($status); // This causes problems on IIS and some FastCGI setups 
  17. header("Location: $location");