bp_get_referer_path()

Return the URL path of the referring page.


Description Description

This is a wrapper for wp_get_referer() that sanitizes the referer URL to a webroot-relative path. For example, ‘http://example.com/foo/‘ will be reduced to ‘/foo/’.


Return Return

(bool|string) Returns false on error, a URL path on success.


Top ↑

Source Source

File: bp-core/bp-core-functions.php

function bp_get_referer_path() {
	$referer = wp_get_referer();

	if ( false === $referer ) {
		return false;
	}

	// Turn into an absolute path.
	$referer = preg_replace( '|https?\://[^/]+/|', '/', $referer );

	return $referer;
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.3.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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