Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function site_referral_check() {
- if (!is_admin()){
- $allowed_host = 'google.com'; // not actual production site
- $theurl = $_SERVER['HTTP_REFERER'];
- $host = parse_url($theurl, PHP_URL_HOST);
- //add console variable for debugging. how I know when $host is blank
- $javascript_ouput = "<script>console.log('Debug Info: " .$host. "');
- </script>";
- echo $javascript_ouput;
- //echo "The allowed host: ".$allowed_host; exit;
- if ( !isset($_COOKIE["site-referral"])) {
- if ($host == $allowed_host) {
- setcookie( "site-referral", "site-referral", time() + 1800, COOKIEPATH, COOKIE_DOMAIN);
- }
- if (!$host == $allowed_host) {
- //Redirect
- wp_redirect('http://google.com' ); exit;
- }
- }
- }
Add Comment
Please, Sign In to add comment