wp_referer_field

Retrieve or display referer hidden field for forms.

Description

(string) wp_referer_field( (bool) $echo = true ); 

The referer link is the current Request URI from the server super global. The input name is _wp_http_referer,, in case you wanted to check manually.

Returns (string)

Referer field HTML markup.

Parameters (1)

0. $echo — Optional. (bool) => true
Whether to echo or return the referer field. Default true.

Usage

  1. if ( !function_exists( 'wp_referer_field' ) ) { 
  2. require_once ABSPATH . WPINC . '/functions.php'; 
  3.  
  4. // Optional. Whether to echo or return the referer field. Default true. 
  5. $echo = true; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wp_referer_field($echo); 
  9.  

Defined (1)

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

/wp-includes/functions.php  
  1. function wp_referer_field( $echo = true ) { 
  2. $referer_field = '<input type="hidden" name="_wp_http_referer" value="'. esc_attr( wp_unslash( $_SERVER['REQUEST_URI'] ) ) . '" />'; 
  3.  
  4. if ( $echo ) 
  5. echo $referer_field; 
  6. return $referer_field;