• Resolved JapeNZ

    (@japenz)


    Hi there,
    I’ve always had trouble using the recaptcha option in Defender but seeing the latest update specifically mentions this being fixed, I deactivated the 3rd party recaptcha plugin I’ve been using and activated it in Defender.

    Unfortunately this evening we’ve had a customer contact us to let us know that they are getting an error message from recaptcha.
    I disabled the Defender recaptcha and enabled the 3rd party version, cleared the cache (WP Rocket) and they were able to complete the checkout without any issues.

    Any idea what might cause the problem?
    Are there any known issues / conflicts, is it possibly a caching issue?

    The other plugin works without issue so I’ll have to stick with that one for now.
    Ideally I’d prefer to not use another plugin, I have a dev site setup for testing if it helps.

    Thanks for your help!

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Support Laura – WPMU DEV Support

    (@wpmudevsupport3)

    Hi @japenz

    Hope this message finds you well.

    Some caching plugins have a Delay JavaScript feature which might cause issues with reCaptcha. Are you using WP Rocket to delay assets?

    Still, after testing on my site I was not able to reproduce the issue, is such a case, could you perform a conflict test? Kindly follow this guide for it https://wpmudev.com/docs/getting-started/getting-support/#conflict-test

    Please let us know the results.

    Best regards,
    Laura

    Ash

    (@ashbryant)

    Following this as I too am having this issue

    Plugin Support Laura – WPMU DEV Support

    (@wpmudevsupport3)

    Hi @ashbryant

    Hope this message finds you well.

    Even though that looks similar we need to investigate case by case.

    Can you create a new thread: https://www.ads-software.com/support/plugin/defender-security/#new-topic-0 so we don’t spam the original thread starter? Thank you.

    Best Regards
    Laura

    Ash

    (@ashbryant)

    @wpmudevsupport3

    I’m not spamming, I’m just following. Should the help you give here doesn’t work, I will (and would have anyway) started a new thread.

    Plugin Support Kris – WPMU DEV Support

    (@wpmudevsupport13)

    Hi @japenz

    We haven’t heard from you in a while, I’ll go and mark this thread as resolved. If you have any additional questions or require further help, please let us know!

    Kind Regards,
    Kris

    Thread Starter JapeNZ

    (@japenz)

    Hi @wpmudevsupport13,

    I wasn’t able to resolve the issue, but think it might be a limitation of V3 rather than the Defender plugin.

    I think the customers that had the problem may have added products from the homepage and gone straight to the checkout. As they hadn’t clicked on the website many times, they weren’t passing the recaptcha V3 test.

    I’ve switched to V2 checkbox and everything seems fine now.

    Thanks for your help.

    Thread Starter JapeNZ

    (@japenz)

    Hello again,
    So it looks like your reCaptcha V2 option has a conflict with PayPal.
    I’ve just had a customer attempt to complete an order and get kicked back to our website to find a reCaptcha error notice.
    The order wasn’t registered on our end, but the payment was attempted twice by PayPal before being reversed.

    We’re disabling recaptcha in Defender as neither version seems to work correctly and the 3rd party plugin we were using didn’t have any issues.

    Plugin Support Dmytro – WPMU DEV Support

    (@wpmudevsupport16)

    Hello @japenz,

    I hope you’re doing great today!

    If you’re using WooCommerce PayPal Payments plugin, the issue might be happening due to captcha being sent twice during checkout.

    In this case, could you please test it again, after adding the following PHP snippet as a workaround:

    <?php
    
    add_action( 'plugins_loaded', function() {
    	if ( ! class_exists( 'WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway' ) ) {
    		return; // "WooCommerce PayPal Payments" is not installed/enabled.
    	}
    	if ( ! defined( 'DEFENDER_VERSION' ) ) {
    		return; // Defender is not installed/enabled.
    	}
    	
    	add_filter( 'wd_recaptcha_check_result', function( $result, $form ) {
    		if ( empty( $_REQUEST[ 'g-recaptcha-response' ] ) && empty( $_POST[ 'g-recaptcha-response' ] ) ) {
    			return $result;
    		}
    		
    		$transient_key   = ! empty( $_REQUEST[ 'g-recaptcha-response' ] ) ? $_REQUEST[ 'g-recaptcha-response' ] : $_POST[ 'g-recaptcha-response' ];
    		$transient_key   = '_wdwc-g-recaptcha-' . md5( $transient_key );
    		$transient_value = get_transient( $transient_key );
    
    		if ( empty( $_REQUEST[ 'wc-ajax' ] ) || 'ppc-create-order' !== $_REQUEST[ 'wc-ajax' ] ) {
    			if ( $result ) {
    				set_transient( $transient_key, true, 60 ); // Save the reCaptcha response for 60 seconds.
    			} else if ( '1' === $transient_value ) {
    				$result = true;
    			}
    			return $result;
    		}
    
    		if ( $result && false === $transient_value) {
    			set_transient( $transient_key, true, 60 ); // Save the reCaptcha response for 60 seconds.
    		}
    
    		return $result;
    	}, 10, 2 );
    });

    – save the code in a text editor as a PHP file, for example: defender-recaptcha-paypal-payments.php, and upload it to /wp-content/mu-plugins/ directory on the server, to make it run as a must use plugin.

    I hope this helps. Please let us know if there’s still any issue.

    Best Regards,
    Dmytro

    Thread Starter JapeNZ

    (@japenz)

    Hi @wpmudevsupport16,

    Thank you for the suggestion.

    We’re testing the Simple Cloudflare Turnstile plugin as an alternative as Google reCaptcha has caused too many issues with customers trying to place orders.

    I’ll certainly keep your suggestion in mind if we end up having to revert back to reCaptcha.

Viewing 9 replies - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.