I want to disable direct access to a certain page..
For example:
I have a contact form that when it is sent it redirects the customer to a thank you page.
Now I want that thank you page to only be accessed through redirection only and if I put the url of the thank you page on the browser I don’t want it to be accessible.
How can I do this with a wordpress page?
An “incomplete” possibility is to check the
$_SERVER['HTTP_REFERER']
variable to see if the value is equal to the URL of the contact page which should be taking you to the thank you page.I say it’s incomplet because if you would display a link to the thank you page on the contact page and the user would click that link, the HTTP_REFERER would be the contact page.
Another possibility would be to generate a unique token which you can add to the thank you page URL (and the current session) and the thank you page could check for the existence and correctness of this token.
I think when you submit the contact form , you should save the form in the database and then generate a success code. Now send this success code to the thank you page, which will then check if the code exists, and if yes, thank you page will be displayed. This way you will be sure of two things
1) Customer view the thank you page only if the customer details are successfully saved.
2) Customer view the thank you page only if the customer has come from contact page.
To implement this, you need to create a separate page template for thank you page.