Skip to content

Instantly share code, notes, and snippets.

@kolbaba
Created February 28, 2020 21:56
Show Gist options
  • Save kolbaba/1b4f8cd5dea080792639ce0bc22e673d to your computer and use it in GitHub Desktop.
Save kolbaba/1b4f8cd5dea080792639ce0bc22e673d to your computer and use it in GitHub Desktop.

Contact Form 7

Contact Form 7 Redirect on Submit (Success)

// Redirect on success 
document.addEventListener( 'wpcf7mailsent', function( event ) {
  location = 'thank-you';
}, false );

No Recaptcha Badge

If you’ve ever had to deal with Contact form 7 recaptcha badge showing up on all pages of the site. This little code snippet will only load the badge on the form page template. You can also modify this to be page ids instead.

function conditionally_load_plugin_js_css(){
	if ( !is_page_template('page--form_template.php') ) {	
		wp_dequeue_script('contact-form-7');
		wp_dequeue_script('google-recaptcha');
		wp_dequeue_style('contact-form-7');
	}
}
add_action( 'wp_enqueue_scripts', 'conditionally_load_plugin_js_css' ); 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment