Is there a way to create a URL (new WP page) that can only be accessed from a specific source?

To explain further, here’s what I”m looking to do:

  1. Create a WP page
  2. Use the URL and implement it in a reader service that is hosted (not downloadable) that in order to read (& access the URL) you would have needed to purchase a subscription.
  3. Allow only visitors coming in from the guide access to the page (would be invisible if user clicked on it and tried accessing it from a different location)

To simplify this explanation, I’m looking for a way to only give access to a specific URL from a specific URL.

Read More

What would be the best route to take? Are there any plugins that could accomplish this?

Related posts

1 comment

  1. Only way to base access on url users come from is to rely on $_SERVER[‘HTTP_REFERER’], but as official php docs says:

    Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.

    One chance is to use a secret key and pass it as variable in the url, then in the template check it against a custom field, something like:

    if ( $_GET['secretkey'] == get_post_meta(get_the_ID(), 'secretkey', true) ) {
       // show the post
    } else {
       echo 'Nothing for you here.';
    }
    

    but everyone knows the key (and add it to the url) will see the post (wherever comes from), so is not really secure.

Comments are closed.