What’s the best way to detect referrer?

I’ve been searching for some WP specific way to detect any referrer. Have an idea?
I know how to do that in PHP but I just want to know if there’s some WP function to do that?

EDIT: here is what I ‘m trying to test =>

$referer = wp_get_referer();
if (  strpos($referer ,'http://wordpress.org') !== false ) echo 'you come from wordpress.org';

3 Answers
3

The best way to check the referrer will depends of what are you trying to do. You can use wp_get_referer() or wp_get_original_referer(), but if you want to check the referer for security reasons you should definitely use other functions like check_admin_referer(), check_ajax_referer(), wp_referer_field() or other of the WordPress Nonces related functions.

Leave a Comment