We use cookies to improve our services and provide a better experience. By continuing to use this site, you agree with our Cookies Policy.

More than 400 step-by-step articles to guide you through online project development.
HomeTutorialsCMS TutorialsWordPressWordPress Administration

How to Change URL After Submitting the Form Successfully

Follow These Steps to Change URL After Submitting the Form Successfully

To change the URL after submitting the form successfully can be easy by using the right WordPress function. In this case, we will be using “wp_redirect()” function that allows to set URL to which we should be redirected after successful form submit.

For example, we would like to redirect visitors to the specific page after they submit a contact form. So we should use “wp_redirect()” function at the end of form submit code. Considering that contact form is sending the email after submitting it, the complete code should look like this:

wp_mail($emailTo, $subject, $body, $headers); 
$emailSent = true; wp_redirect( 'URL', 301 ); 

Please note, replace ‘URL’ with the link to the page to which visitors will be redirected. As we can see this function can be used to redirect visitors after submitting the contact form to the page which would show let’s say “Thank you for contacting us, we will respond shortly.” Of course, it can be used anywhere it might be useful.

Rate this Tutorial:
No CommentsLeave a Comment

Other (182)

Popular Keywords