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') );
}
}
?>
Related Posts:
- How to setcookie if is_page(‘page’) ? should I use add_action(‘init’) or there is another action?
- Can I “protect” a page with a form asking for an email address?
- if is_page() is not working with wp_redirect
- Allowing user to edit only certain pages
- How to update page status from publish to draft and draft to publish
- Customizing the URLs of WordPress Login and Sign-up Pages?
- How to add a specific widget to only 1 page?
- Add a Page without header and menus?
- Find empty pages or pages which have less than x characters
- How to add or remove metabox each page separately?
- How to display list of child pages of parent page in wordpress?
- Hide page visual editor if template is selected – redux
- Page template gives ‘Parse error: syntax error’ when used, but no error found!
- more tag in the $post->content when get_pages were used
- Different “Text Widgets” in Sidebar on Many Different Pages?
- How to get the list of posts in a static page other than front page?
- Using JavaScript and JQuery in Page
- How can I make Disqus comments not show up on pages?
- CMS: Making complex pages editable by the end user
- Guidelines for adding static pages
- Show child pages when on a child page
- Sitewide page on all the blogs in the network
- How to create a page when a theme is activated?
- How to echo excerpts with wp_list_pages?
- Remove pages from backend list *and* update counter accordingly
- Creating a form contact page?
- Proper way to implement/access a built-in page in my theme
- Displaying page content in category archive (archive.php)
- Is it possible to skip certain specified pages when using < prev and next > links?
- Custom Page Order instead of Alphabetical
- How to redirect a page to another?
- How to create a page that lists all the experts(Users with same access permission as author)?
- Get the ‘Content Permission’ roles as defined in a page
- Pages are hashed as of today
- Create a page that’s to not be indexed or accessible via slug
- Dynamic Landing Page
- My custom template page not loading content inside it?
- Can a user find a child page?
- What is a subpage in WordPress?
- Get $post Object from another page
- Is it possible to activate page template without manually selecting it in wp-admin?
- Excerpt Now Showing on the Post Page
- How can I use “getarchives_where” to get monthly archives for static pages?
- Google Page Speed Insights not recognising WP-Cofig settings?
- Only Display a Featured Image on First Post Page
- Link to Particular Page Within Template PHP Code
- If I use a static page-slug.php for a page, is the database still queried?
- How do I quickly hide a hierarchy of pages from search engines and external users?
- How to store archived copies of a WordPress site
- Changes in WordPress taking 48hrs to reflect [closed]
- Avoid pages losing template association on site re-deploy
- get_permalink not fetching correct pages
- Remove Duplicate Pages so only original exists
- Best way to organize data in this scenario
- How to get tagged pages to show up with tagged posts?
- wp_query issue with post_type = page
- Query pages based on tags
- How do I centre all page titles site wide without centring post titles or site title?
- create 2 custom columns in page edit in Admin panel
- Authors posts on a author created page
- Check if page has subpages
- Suggestions: Customizable header image and style colors that are different for each page
- WordPress rewrite rule for specific page and second parametr doesnt work
- how to change permalink for dynamic page without 404 error
- Page and admin doesnt load – i tried everything
- Create many pages with dynamic content based on 1 template
- wp_list_pages get the hole hierarchy for current page
- My English homepage will not update
- Problem with deleting a “Page”
- Static Home Page resets to Front Page
- Removing add new pages form editor role
- Hidden Pages, Posts & Plugins
- Editing pages from dashboard
- WordPress comments section on pages not appearing
- Pagination For Page Post Type
- Edit Page Content not showing
- Managing many pages on a WordPress website
- custom page or standalone page?
- Avada Theme – Display results from a specific category [closed]
- Multiple pages to show posts
- How to finish this loop?
- Is it possible to rewrite a page url Without setting the permalinks to Post Name?
- All the pages are blank [closed]
- Get ID of the page where shortcode is included
- How to achieve anchor links on top of pages.
- how to list subpages in sidebar without widget
- Static front page with excerpt
- How can I show the content of all pages (with links) on a single page?
- Passing form data via AJAX to REST API And displaying results
- Footer doesn’t display in page.php
- Load new Posts on Scroll on Page
- Default pages to be unpublished – possible?
- if and else statement not working on the iframe php page
- How to set a default page for load first time?
- Display multiple page contents under single page
- Split Page Links
- Ask for template when adding a new page
- I reached halfway through a WordPress tutorial to find out I began wrong for a new comer to WP
- Can’t create new pages in wordpress
- Custom template is not showing up in templates dropdown list after re-naming it