wp_get_raw_referer() WordPress Function

The wp_get_raw_referer() function is used to retrieve the raw URL of the referring page. This is useful for retrieving the URL of a page that has been redirected.

wp_get_raw_referer() #

Retrieves unvalidated referer from ‘_wp_http_referer’ or HTTP referer.


Description

Do not use for redirects, use wp_get_referer() instead.


Top ↑

Return

(string|false) Referer URL on success, false on failure.


Top ↑

Source

File: wp-includes/functions.php

function wp_get_raw_referer() {
	if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) {
		return wp_unslash( $_REQUEST['_wp_http_referer'] );
	} elseif ( ! empty( $_SERVER['HTTP_REFERER'] ) ) {
		return wp_unslash( $_SERVER['HTTP_REFERER'] );
	}

	return false;
}


Top ↑

Changelog

Changelog
VersionDescription
4.5.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More