bp_get_referer_path

Return the URL path of the referring page.

Description

(bool|string) bp_get_referer_path(); 

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/.

Returns (bool|string)

Returns false on error, a URL path on success.


Usage

  1. if ( !function_exists( 'bp_get_referer_path' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-core/bp-core-functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bp_get_referer_path(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/bp-core/bp-core-functions.php  
  1. function bp_get_referer_path() { 
  2. $referer = wp_get_referer(); 
  3.  
  4. if ( false === $referer ) { 
  5. return false; 
  6.  
  7. // Turn into an absolute path. 
  8. $referer = preg_replace( '|https?\://[^/]+/|', '/', $referer ); 
  9.  
  10. return $referer;