• Resolved robwoodgate

    (@robwoodgate)


    Hi guys, it looks like CF7 may have changed the format of their output as the “has-spinner” class has moved, which means any form without the manual shortcode is failing if the cfturnstile_cf7_all option is set.

    The current code is brittle and sensitive to such changes, or indeed any custom classes being used.

    It would be more robust if you replace lines 43-56 of
    inc/integrations/forms/contact-form-7.php:

    $button_types = array(
    	'<input type="submit"',
    	'<input class="wpcf7-submit" type="submit"',
    	'<input class="wpcf7-form-control wpcf7-submit" type="submit"',
    	'<input class="wpcf7-form-control has-spinner wpcf7-submit" type="submit"',
    	'<input class="wpcf7-form-control has-spinner wpcf7-submit button button--secondary" type="submit"',
    );
    $button_types = apply_filters( 'cfturnstile_cf7_button_types', $button_types );
    foreach($button_types as $button_type) {
    	if (false !== strpos($content, $button_type)) {
    		$content = str_replace($button_type, cfturnstile_cf7_shortcode() . '<br/>' . $button_type, $content);
    	}
    }
    return $content;

    with a simple preg_replace:

    return preg_replace('/(<input[^>]*type="submit")/i', cfturnstile_cf7_shortcode() . '<br/>$1', $content);

    This will ensure the turnstile is added before the submit button, regardless of the classes set.

    • This topic was modified 1 year, 7 months ago by robwoodgate.
    • This topic was modified 1 year, 7 months ago by robwoodgate.
    • This topic was modified 1 year, 7 months ago by robwoodgate.
Viewing 7 replies - 1 through 7 (of 7 total)
  • Thank you so much for sharing this solution. However, I could not find the path – inc/integrations/forms/contact-form-7.php.

    Can you tell me where I can find it precisely so that I can replace the lines 43-56 with the code given by you?

    • This reply was modified 1 year, 7 months ago by cocoa1. Reason: Notify me of follow-up replies via email
    Thread Starter robwoodgate

    (@robwoodgate)

    @cocoa1 – the path I gave is relative to the plugin folder… so from in your WP install, it will be ../wp-content/plugins/simple-cloudflare-turnstile/inc/integrations/forms/contact-form-7.php

    I fixed this issue by placing [cf7-simple-turnstile] above the submit button in contact form field.

    It solved the issue on one site and Turnstile was working perfectly fine. However, on other site I still don’t see the Turnstile captcha.

    Why is it happening? On one it’s site running fine and on another it’s not working. What could possibly go wrong?

    Thanks for the suggestion @robwoodgate

    I will test this and look into implementing it in the next update.

    Hi,

    Please could you update to the latest version (1.23.0) and give this another try? This fix has now been implemented.

    Sure. I will update the plugin and let you know.

    Thread Starter robwoodgate

    (@robwoodgate)

    Hi Elliot, have updated and tested and the fix is all good.

    Cheers
    Rob

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘CF7 All Forms Issue – suggested fix’ is closed to new replies.