0

I would like to restrect access to one page in a wordpress website, so that the page is only accessible to users coming from a specific website. Lets say my wordpress website is www.wptest.com and the page www.wptest/tickets should be accessible only to the users coming from the website www.eventorganisatortest.com/register How is that possible with Javascript? I have a solution with php, but I would like a javascript one. I know, it could be easily spoofed, but it doesn't matter, as our users are not that experienced, and even if they do it, it's not a big deal.. We just make our effort so that they register first on the www.eventorganistortest.com website and click on the button "Buy Tickets" on it, to get redirected to our portal www.wptest/tickets and buy their tickets.

Here is the php code that could do that actually..

PHP Allow access to specific referrer url/page only

Community
  • 1
  • 1
ZelelB
  • 1,836
  • 7
  • 45
  • 71

1 Answers1

0

You would restrict them using the below code and a conditional.

 string = document.referrer; 

https://developer.mozilla.org/en-US/docs/Web/API/Document/referrer

Alex Rindone
  • 296
  • 2
  • 9
  • why the downvote? They asked for a javascript answer. I wouldn't do it myself per se, but this is what they asked for. – Alex Rindone Aug 07 '18 at 14:10