// Redirect on success
document.addEventListener( 'wpcf7mailsent', function( event ) {
location = 'thank-you';
}, false );
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' );