Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save dwanjuki/98d646e561cfd1ff7cfd462d636b174d to your computer and use it in GitHub Desktop.

Select an option

Save dwanjuki/98d646e561cfd1ff7cfd462d636b174d to your computer and use it in GitHub Desktop.
Disable Contact Form 7 reCAPTCHA on the checkout page for PMPro
<?php
/**
* This recipe stops Contact Form 7's reCAPTCHA script from loading
* on the PMPro checkout page.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_disable_contact_form_7_recaptcha_on_checkout() {
// Bail if CF7 or PMPro inactive.
if ( ! defined( 'WPCF7_VERSION' ) || ! function_exists( 'pmpro_is_checkout' ) ) {
return;
}
// Dequeue CF7 reCAPTCHA script if we're on a PMPro Checkout page.
if ( wp_script_is( 'wpcf7-recaptcha', 'enqueued' ) && pmpro_is_checkout() ) {
wp_dequeue_script( 'wpcf7-recaptcha' );
}
}
add_action( 'wp_print_scripts', 'my_pmpro_disable_contact_form_7_recaptcha_on_checkout' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment