Support » Plugin: Contact Form 7 » 3-SPAM Fixes / Contact Form 7 (v5.1)

  • Resolved wpwd2016


    There are many who do not read the other posts to find the fix, so before too many post the same issue, here are the fixes that work.

    Use only 1 of these workarounds until the developer fixes the issue.

    == Fix 1 ==
    Using CF7 5.1 & Google v3 recapatcha keys

    Go via FTP or CPanel at your hosting service accessing using their file manager, go to: “/wp-content/plugins/contact-form-7/modules/recaptcha.php”

    Go to line 112,

    Find: “return $spam;”
    Change it to: “return true;”

    Save changes.

    This one worked for me, spam has stopped and messages sent successfully.

    == Fix 2 ==
    Remove any v3 Google keys from CF7 Integration and remove the CF7 shortcode [recaptcha] from the form settings , then save.

    Install/Activate plugin “Advanced-nocaptcha-recaptcha”

    Go to settings of this plugin, insert Google v2 reCaptcha keys, choose any of the other settings.

    Use the plugin’s shortcode – [anr_nocaptcha g-recaptcha-response] , insert that shortcode into CF7 Form settings where you previously inserted the shortcode for reCaptcha.


    == Fix 3 ==
    Remove any v3 Google keys from CF7 Integration and remove the CF7 shortcode [recaptcha] from the form settings , then save.

    Install/Activate Plugin “Math Recpatcha”.

    Go to the settings for Math ReCaptcha and check “Contact For 7”

    Go to Contact Form 7 settings and there is a button to insert the Math ReCaptcha.

    (this math captcha plugin/add-on does not need Google reCaptcha keys and it works)


    Any one of the above fixes the spam issues and you can still use Contact Form 7 (CF7)

    • This topic was modified 9 months ago by  wpwd2016. Reason: more info
Viewing 11 replies - 46 through 56 (of 56 total)
  • @newrone

    Here are the settings I have for my Math Captcha (dFactory) plugin.


    If copying my settings makes no difference, something else is conflicting with the plugin. If so, then test things before you get any answer from the other forum.

    Test by deactivating all other plugins other than CF7 and Math Captcha.

    If that still gets the error, then activate one of the default themes in WordPress and test again.

    Note: A google search of the error you got gave some results,

    Link: Google Search Results

    Apparently cache plugins can cause problems.



    Fix 1 worked for me too

    Checking the code and working out the problem with the some of the customers I realized that the problem is in anti-virus (anti-fishing, anti-ad, anti-banner) software, installed on the customer’s system. The Fix 1 change to return TRUE is reCapture hasn’t started istead of FALSE in original script. Because I use both v2 and v3 for the different function in the same web-site I have notices that many of the customers who clime on spam in CF7 form clime to invisibility v2 in the other forms and have both problem resolved just after switching off anti-… software. By myself I use Kaspersky protection which works very inteligent and don’t make any problems, but there are a lot of a lot of unknown apps, that blocks all hidden or asynchronous processes, o processes that collect some user activity information.

    So, this bug con’t be fixed neither by CF7 developers nor Google, as it’s the result of the interfering the side apps. The only solution that I’d advice to improve into CF7 is to set parameter whether should CF7 return SPAM if the Google reCapture hasn’t started or let it to pass.



    why you don’t use quiz option in contact form 7 to avoid spam. I think its best either confusing with more plugins.

    The fixe 1 worked for me but not on line 112.
    there is 2 times “return $spam;” in the code recaptcha.php
    it is the first one you must edit not the second one, in my file line 99
    see below:

    add_filter( ‘wpcf7_spam’, ‘wpcf7_recaptcha_verify_response’, 9, 1 );

    function wpcf7_recaptcha_verify_response( $spam ) {
    if ( $spam ) {
    return true;

    $service = WPCF7_RECAPTCHA::get_instance();

    if ( ! $service->is_active() ) {
    return $spam;

    thanks for your help wpwd2016!

    Because Name Already Exists


    However — that’s weird — when testing the form, after clicking the send button the form displays two error messages:

    “Please solve Captcha correctly.” <– in red font before the send button, and

    “Validation errors occurred. Please confirm the fields and submit it again.” <– in yellow frame after the send button.

    I have same issue, Advanced-nocaptcha-recaptcha working fine on others page (login, register, etc), except CF7

    Step 2 worked for me but first I had to undo Step 1. With changed made like in Step 1, Step 2 wont work. But if you let return $spam; how it is Step 2 will work.

    I’m very happy about the solution right now. I had no spam problems but that because of reCaptcha v3 in CF7 generally no mails could be sent. I was desperate because I couldn’t fix the problem. Now it works. Thank you very much!

    Hi @mwarbinek

    Just wanted to thank you and let you know that “== Fix 1 ==” worked for me. Although it wasn’t on line 112 it was like 97 and something else. I changed both lines and it works now.




    Thank you so much for this post. I used fix 2. I tried fix 3 but it messed up the styling. Fix 2 is perfect.




    This post was made to address Spam issues when CF7 switched to reCaptcha v3 for the first time and it was not working. Then, at that time, it was line 112. Since CF7 was updated and that changed file “recaptcha.php”, which is why you find it around line 97.



    Thanks for this thread – was running into the same problem and #2 worked perfectly.

    • This reply was modified 4 months ago by  HaeckDesign.

    Fix #2 worked for me, as well. That plugin supports v3, as well, so I’m using my v3 keys, currently. So far, so good. I removed my v3 keys from the CF7 integration section and applied the new plugin’s shortcode before the submit button in the form.

    I sent a test form, which went through correctly (not auto-flagged as spam) and triggered my Thank You page as intended.

    I tried fix #1 first, but when I searched for “return $spam;” there were 3 different results found in the recaptcha.php file, so I wasn’t sure which to change (with the change in line numbers, etc.). I opted for not messing with that and trying #2 instead. 😉

    Thank you!

Viewing 11 replies - 46 through 56 (of 56 total)
  • You must be logged in to reply to this topic.