wp_get_referer

Retrieve referer from '_wp_http_referer' or HTTP referer.

Description

(false|string) wp_get_referer(); 

If it's the same as the current request URL, will return false.

Returns (false|string)

False on failure. Referer URL on success.


Usage

  1. if ( !function_exists( 'wp_get_referer' ) ) { 
  2. require_once ABSPATH . WPINC . '/functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wp_get_referer(); 
  7.  

Defined (1)

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

/wp-includes/functions.php  
  1. function wp_get_referer() { 
  2. if ( ! function_exists( 'wp_validate_redirect' ) ) { 
  3. return false; 
  4.  
  5. $ref = wp_get_raw_referer(); 
  6.  
  7. if ( $ref && $ref !== wp_unslash( $_SERVER['REQUEST_URI'] ) && $ref !== home_url() . wp_unslash( $_SERVER['REQUEST_URI'] ) ) { 
  8. return wp_validate_redirect( $ref, false ); 
  9.  
  10. return false;