2
votes

I created a custom form using contact form 7 plugin in wordpress. I dont want to send any mail . I just want to submit a form on a specific page and save data into database and third party api called with form data and also if any error getting display error on form and if data saved successfully then redirect to success page.

1

1 Answers

4
votes

Use this code to redirect to success page after submit in "additional setting" of contact form 7

on_sent_ok: "location.replace('http://www.example.com/thank-you');" 

It will redirect to thankyou page after successfully submission.

Also you can use this plugin to store data in database

EDIT FOR LATEST VERSION

The method using the on_sent_ok hook is no longer recommended so the simplest way is utilizing CF7 custom DOM event to run JavaScript when the wpcf7mailsent event occurs.

Example Code

<script>
document.addEventListener( 'wpcf7mailsent', function( event ) {
  location = 'http://example.com/thank-you';
}, false );
</script>