W3cubDocs

/WordPress

wp_get_raw_referer(): string|false

Retrieves unvalidated referer from the ‘_wp_http_referer’ URL query variable or the HTTP referer.

Description

If the value of the ‘_wp_http_referer’ URL query variable is not a string then it will be ignored.

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

Return

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

Source

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

	return false;
}

Changelog

Version Description
4.5.0 Introduced.

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_get_raw_referer