Support » Plugin: Contact Form 7 » grecaptcha is not defined

  • Resolved blindpet


    After updating to the latest version I now get this error ‘grecaptcha is not defined’:

    	var wpcf7recaptcha = {
    		execute: function() {
    				{ action: 'homepage' }
    			).then( function( token ) {
    				var forms = document.getElementsByTagName( 'form' );
    				for ( var i = 0; i < forms.length; i++ ) {
    					var fields = forms[ i ].getElementsByTagName( 'input' );
    					for ( var j = 0; j < fields.length; j++ ) {
    						var field = fields[ j ];
    						if ( 'g-recaptcha-response' === field.getAttribute( 'name' ) ) {
    							field.setAttribute( 'value', token );
    			} );
    	grecaptcha.ready( wpcf7recaptcha.execute );

    The v3 recaptcha is also not working very well and lets a lot more spam in 🙁

    The page I need help with: [log in to see the link]

Viewing 11 replies - 1 through 11 (of 11 total)
  • Here is another error from the console:

    Uncaught TypeError: wpcf7.initForm is not a function
        at HTMLFormElement.<anonymous> (scripts.js:33)
        at Function.each (jquery.js:2)
        at a.fn.init.each (jquery.js:2)
        at HTMLDocument.<anonymous> (scripts.js:31)
        at i (jquery.js:2)
        at Object.add [as done] (jquery.js:2)
        at n.fn.init.n.fn.ready (jquery.js:2)
        at a.fn.init.n.fn.init (jquery.js:2)
        at new a.fn.init (jquery-migrate.min.js:2)
        at n (jquery.js:2)

    Rolling back to 5.1 has resolved this issue so the bug exists in 5.1.1 it seems

    Plugin Author Takayuki Miyoshi


    Thank you, rolling back to 5.1.0 fixed the issue with the contact form not sending, I believe I was not getting any spam because 5.1.1 broke with its update not due to any improvements with recaptcha in 5.1.1. I do have wp_footer in my theme I believe so this wouldn’t explain the failure I don’t think

    • This reply was modified 8 months, 3 weeks ago by  blindpet.

    For those having the same problem but can’t ask their theme developer to make an updated, you can add <script src=”” async defer></script> just before </head> to make contact form 7 work again.

    fatherb = the hero we don’t deserve! Thank you, kind sir!

    This can also be caused by CloudFlare’s Rocket Loader!

    For a simple fix, I installed a WP Plugin:

    Adding the following to Turn RocketScript Off For:

    Then purge the Cloudflare cache and WP caching plugins. Alternatively, this can also be done through CloudFlare page rules, if you have any left.

    I had this issue too, I tried several of the fixes above. I had wp_footer(), I was using v5.1.1. But the user inserted reCaptcha v2 keys instead of reCaptcha v3 keys, I put in the v3 keys and it worked just fine.

    • This reply was modified 4 months, 2 weeks ago by  OrlandoWebDev.

    I’ve the same error and also I do not load the CSS of the child theme. But when I add the script at least the css is loaded. But the error keeps coming up in the console.

    I am not sure this will help you now or not. I had same issue and I updated reCAPTCHA key with V3. Might be you had old v2 key configured.
    Ref :
    Please make sure all reCAPTCHA should use version 3 now.

    I hope this will help you.

    If you use the “Async JavaScript” plugin, you need to insert “api.js” under “Scripts to Exclude”.
    So neither async nor defer get applied during page load.
    Problem solved.

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