bp_get_referer_path()
Return the URL path of the referring page.
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
(bool|string) Returns false on error, a URL path on success.
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;
}
Changelog
| Version | Description |
|---|---|
| BuddyPress 2.3.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.