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:
<?php
setcookie( 'my_cookies_name', true, 0 ); // This cookie will expire after the session
?>
Retreiving the cookie (on /page2
‘s php template:
<?php
if( is_page('page2') ) {
// Because the value is set to true, you can just check for the value in if()
if( ! $_COOKIE['my_cookies_name'] ) {
// cookie isn't found, redirect back
wp_safe_redirect( site_url('/page1') );
}
}
?>