Skip to content

Instantly share code, notes, and snippets.

@ipokkel
Last active June 2, 2021 08:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ipokkel/a6bbe2aff703a5b0df8754cd6c0440d6 to your computer and use it in GitHub Desktop.
Save ipokkel/a6bbe2aff703a5b0df8754cd6c0440d6 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' );
@ipokkel
Copy link
Author

ipokkel commented Jan 7, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment