Gavin
Gavin

Reputation: 7942

CF7 with JavaScript Disabled – After form submit, refreshing page resubmits form

I prefer to do all the styling and JavaScript functionality myself, so in wp-config.php I’ve set the following:

define( ‘WPCF7_LOAD_JS’, false );
define( ‘WPCF7_LOAD_CSS’, false );

On submit everything is fine. It reloads the page and shows the success message. The problem is if I refresh the page again it resubmits the form. There is no post data that gets resubmitted, so CF7 must be using the form submission hash that gets added onto the URL. Shouldn't it recognize this hash exists already and not submit the form again?

I can’t find anything on Google about this. Does anyone know how to stop this from happening?

Upvotes: 1

Views: 936

Answers (1)

Rajkumar Gour
Rajkumar Gour

Reputation: 1159

you have to redirect the page to thank you page after mail sent using contact form 7 hook

add_action('wpcf7_mail_sent', function ($cf7) {
    global $post;
   wp_redirect(site_url('thank-you');
   exit;
});

Upvotes: 1

Related Questions