Lets say, I create page1 and page2 in wordpress, in Page1 there is a hyperlink which takes me to page2. How do I ensure that visitor has clicked that hyperlink and have come to page2 and not directly on page2, by typing page2 url in the address bar.
if someone has come directly to page2 I want them to be redirected automatically to page1.
In old days I was able to crack this with some javascript and and later also in ASP.
If I recollect correctly had used querystring and url redirect.
What is easy way in wordpress? unfortunately in wordpress plugin directory all I am getting is plugins for 404 and 301, Please help me here.
As a complimentary addition to Kaiser’s answer you can secure things further by using a nonce value. (numbers used once)
Step 1 – create your link with nonce value
Page A (the referring page where your users are coming from)
This will create a link like,
Step 2 – verify the nonce value passed from link
Page B (where you users are going once they click the above link)
This checks for the existence of a nonce via the $_GET parameter
_wpnonce
and whether the action/namesecure_this_page_nonce
is set which equates to this portion of the URL as shown in Step 1?_wpnonce=8c9xa6e33e
.If the nonce value is not present and fails its conditional check then you can redirect the user back to the previous page.
If it passes the conditional check then the user has originated from clicking our link on Page A, in which case we render the page as normal.
Good luck!