wp_original_referer_field

Retrieve or display original referer hidden field for forms.

Description

(string) wp_original_referer_field( (constant) $echo = true, (string) $jump_back_to = 'current' ); 

The input name is _wp_original_http_referer and will be either the same value of wp_referer_field(), if that was posted already or it will be the current page, if it doesn't exist.

Returns (string)

Original referer field.

Parameters (2)

0. $echo — Optional. (constant) => true
Whether to echo the original http referer. Default true.
1. $jump_back_to — Optional. (string) => 'current'
Can be previous or page you want to jump back to. Default current..

Usage

  1. if ( !function_exists( 'wp_original_referer_field' ) ) { 
  2. require_once ABSPATH . WPINC . '/functions.php'; 
  3.  
  4. // Optional. Whether to echo the original http referer. Default true. 
  5. $echo = true; 
  6.  
  7. // Optional. Can be 'previous' or page you want to jump back to. 
  8. // Default 'current'. 
  9. $jump_back_to = 'current'; 
  10.  
  11. // NOTICE! Understand what this does before running. 
  12. $result = wp_original_referer_field($echo, $jump_back_to); 
  13.  

Defined (1)

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

/wp-includes/functions.php  
  1. function wp_original_referer_field( $echo = true, $jump_back_to = 'current' ) { 
  2. if ( ! $ref = wp_get_original_referer() ) { 
  3. $ref = 'previous' == $jump_back_to ? wp_get_referer() : wp_unslash( $_SERVER['REQUEST_URI'] ); 
  4. $orig_referer_field = '<input type="hidden" name="_wp_original_http_referer" value="' . esc_attr( $ref ) . '" />'; 
  5. if ( $echo ) 
  6. echo $orig_referer_field; 
  7. return $orig_referer_field;