Form handling needs to happen in functions.php
(or equivalent) so that it triggers before headers are sent. Here is the how I achieved redirection after form submit:
add_action('init', 'redirectAfterSubmit');
function redirectAfterSubmit() {
if (isset($_POST["submit"])) {
insert_row();
wp_redirect( "/thank-you", 301 );
die();
}
}
function insert_row(){
// form handing here
}
Related Posts:
- Query WP data with the WPDB API from outside WordPress
- How to redirect user to a page after form submission
- How to pass email values from one php page to another
- Remove #wpcf7-f2450-o1 with Contact form 7 redirect [closed]
- WP_List_table with form of method=GET redirects to wrong url after submit
- Display Freebie Page Content only if Referrer is from Form Page
- simple wordpress form redirection
- Select post from dropdown and add query args not working
- Subdomain redirect problem
- Make a treatment before the action of the form
- Why is WordPress redirecting to homepage after GET form submit?
- Custom Form Redirects to Post after Submit
- noheader on the user/frontend side
- Create a custom redirect link that tracks the first visited page and after submitting form goes to first page using formidable forms plugin? [closed]
- How do I skip wordpress’s 404 handling and redirect all 404 errors for static files to 404.html?
- Disable WordPress URL auto complete
- WordPress redirecting connections on port 8080 to 80
- 301 redirect instead of 404 when URL is a prefix of a post or page name?
- Redirect to referring page after logging in
- Redirecting WordPress /.htaccess / HSTS / SSL
- Htaccess redirect from ‘/%postname%.html’ to ‘/%postname%’
- Redirect to post after submission with Gravity Forms? [closed]
- Redirect www to non-www htaccess
- Using redirection plugin to pass URLs as lowercase to wordpress
- Prevent redirect to page/page when reserved term ‘name’ in $_POST when value is a page/post title
- Redirect to login page
- Import WordPress Post Slug with Forward Slash
- Create a php callback/endpoint for an OAuth script
- Get the final destination after WP_Http redirects (WordPress)
- Too many redirects when using wp super cache [closed]
- How does WordPress redirect without using .htaccess?
- How to redirect from various ?page_id= to home page?
- header and wp_redirect not working. cannot modify header information warning
- Code to create a redirection after login?
- Redirect 301 www.my-site.com/page/n to www.my-site.com/ [closed]
- Redirect not logged in users if they are on a specific page
- Headless WordPress redirect front-page to login page [closed]
- How to set up a single portfolio page as home page?
- 301 Redirect To Post ID
- Redirect after password update
- How code a redirect back to page from form thanks
- How to add new redirection on wordpress site
- How to use Regex to add to a url?
- htaccess redirect invoice.php to /client/invoice.php
- redirect wp-admin/install.php
- Redirect homepage with htaccess, except if I enter the link adding “/home”
- How to properly encode url with parameters for redirect_to
- How to disable redirect on pagination first page
- Redirect user to a form until they have filled it out [closed]
- Buddyboss Platform plugin causing “too many redirects”
- Redirections and rewrites to subdomain
- Redirect user to previous page after signup from custom form
- How To Fix 404 errors caused by Google Indexing WordPress In Subdirectory
- Unable to access folders in same level as wordpress installation
- 301 Redirect all page and post urls from .html to /
- Get query parameters from external url and make a redirection
- Why does specifying ‘about-us’ as a link target take longer than specifying ‘about-us/’?
- Internal Links that Automatically Update
- Usage of the login_redirect filter
- Show different page for first time user
- Redirecting to new URL structure and 301
- Blog has an infinite redirect loop
- WP forwarding to wrong site address
- How can I redirect users on the new 404 page without plugin?
- How do I write a subdomain redirect?
- Redirection on domain name
- htaccess redirect from specific urls of my site to the homepage
- Can’t make redirect in WordPress
- Changing permalinks and redirecting urls
- Preventing Canonical Redirect for CDN
- Mass .htaccess URL Forwarding
- How to point a public URL to internal (hidden) server with all links following.
- Wp Remote get with manual redirect
- Redirect posts to new domain
- 302 Redirect is showing in the audit but links are opening separately
- How do I redirect the browser to 404 page, if no posts are found in home page
- Redirect after the registration
- Conditional Login Redirect
- How to redirect if 404 error in wordpress then redirect 404.php url
- 301 Redirects from old WordPress domain
- Unexpected: WordPress redirects to the WP_HOME/WP_SITEURL value
- Automatically switch language based on visitor’s country
- Do redirect 301 for wordpress page
- How to make front page temporarily show content of internal page
- How to get user details by name
- custom error message or redirect to custom page if any error occurs
- One set of Child Pages redirecting to Home page?
- Redirect old .html URLs to a new installation in a subfolder
- Blog post URL redirects to a Page URL who’s slug is a prefix of the post slug.
- Blog posts redirecting to random 404 pages
- WordPress 302 Redirect to Holding Page
- Converted posts to a CPT, 301 redirects necessary?
- Rewrite rule to redirect to a particular filename.php
- Redirect to other page when mobile
- Why my htacess rewrite return 404?
- problem redirecting users to page on login
- Redirecting to page on form submit – Revue plugin
- How to redirect non-logged in users to wordpress login page and bypass some page IDs?
- Is there a way to redirect people from a page on my .com website to a corresponding page on my .co.uk website if they are in the UK
- How to find out what is causing redirect of static content?