Skip to content

Instantly share code, notes, and snippets.

@femiyb
Forked from ipokkel/disable-cf7-recaptcha.php
Created June 2, 2021 08:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save femiyb/32af60cd5cf03db6937d66d38d0b92e2 to your computer and use it in GitHub Desktop.
Save femiyb/32af60cd5cf03db6937d66d38d0b92e2 to your computer and use it in GitHub Desktop.
Disable Contact Form 7's recaptcha on the checkout page for PMPro. #pmpro #paid-memberships-pro #wpcf7 #cf7 #recaptcha
<?php
/**
* This recipe stops Contact Form 7's recaptcha javascript from loading
* on the PMPro checkout page. This helps prevent conflicts from recaptcha
* being loaded twice.
*
* 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 disable_cf7_recaptcha_on_pmpro_checkout() {
global $pmpro_pages, $recaptcha;
if ( defined( 'WPCF7_VERSION' ) && is_page( $pmpro_pages['checkout'] ) && $recaptcha ) {
wp_dequeue_script( 'google-recaptcha' );
}
}
add_action( 'wp_print_scripts', 'disable_cf7_recaptcha_on_pmpro_checkout' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment