I am looking for a way to solve the following problem:
User should only be able to visit mywebsite.com/page2/
after they visited mywebsite.com/page1/
If a user was not on page1, s/he should not be able to visit page2.
Is this possible?
Further specification: On page1 should be a survey (plugin: “Contact Form 7”) and people are redirected to page2 after submitting their answers.
You could set a cookie upon contact form submission, then check for the cookie on
/page2
. If it is not found,wp_safe_redirect()
back to/page1
.Setting a cookie – You will need to hook into Contact Form 7’s submission – look into their documentation:
Retreiving the cookie (on
/page2
‘s php template: