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
if ( !function_exists( 'wp_get_referer' ) ) { require_once ABSPATH . WPINC . '/functions.php'; } // NOTICE! Understand what this does before running. $result = wp_get_referer();
Defined (1)
The function is defined in the following location(s).
- /wp-includes/functions.php
- function wp_get_referer() {
- if ( ! function_exists( 'wp_validate_redirect' ) ) {
- return false;
- }
- $ref = wp_get_raw_referer();
- if ( $ref && $ref !== wp_unslash( $_SERVER['REQUEST_URI'] ) && $ref !== home_url() . wp_unslash( $_SERVER['REQUEST_URI'] ) ) {
- return wp_validate_redirect( $ref, false );
- }
- return false;
- }