wp_get_referer()

Retrieve referer from ‘_wp_http_referer’ or HTTP referer.


Description Description

If it’s the same as the current request URL, will return false.


Return Return

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


Top ↑

Source Source

File: 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;
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.0.4 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.