Check from which page the user is coming to the current page in wordpress

I want to check if a user comes from a specific page to the current page.

e.g

Read More
if (user comes from /bingo.php) 
  { wp_redirect( /newpage.php );exit; }
else { // do nothing };

thank you 🙂

Related posts

Leave a Reply

2 comments

  1. Without completely answering your question, I’d say you could look into $_SERVER['HTTP_REFERER']. This contains the previous page your user came from. Please note that this is not always set.

  2. Here is my code for my case:

    if (!is_user_logged_in() ) {
    $icamefrom = $_SERVER['HTTP_REFERER'];
    if ( $icamefrom == 'the_site_you_want_to_check') { wp_redirect( '/signup' ); exit; }; 
    }