• I was able to successfully add the ReCaptcha keys and get the recaptcha form to appear in the plugin’s settings.

    Though the actual form that shows up on the site does not include the ReCaptcha form.

    I get this error in my Console:
    ReCAPTCHA couldn’t find user-provided function: onloadCallback2810171

    I searched through your code and can find no callback function.

    A little help please?

Viewing 1 replies (of 1 total)
  • Thread Starter roddyguy

    (@roddyguy)

    Well, I dad to do my own hacking to get this to work. This is what I did in order to get ReCaptcha to work:

    In class-emma-form.php starting at line 410, I changed:

    $emma_form .= '<script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback' . $form_unique . '&render=explicit" async defer></script>

    to

    $emma_form .= '<script src="https://www.google.com/recaptcha/api.js" async defer></script>

    Then just below this is some included Javascript. The problem is that using this in short code content wraps any line breaks containing spaces in <p> tags and breaks the code. So I changed this:

    	        	$emma_form .= '<script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback' . $form_unique . '&render=explicit" async defer></script>
    	        	<script type="text/javascript">
    	        		
    	        		if ( typeof captchaExists == "undefined" ) {
    		        		var captchaExists = true;
    		        	} else {
    			        	captchaExists = true;
    			        }
    		        	
    		        	if ( typeof captchaInit == "undefined" ) {
    			        	var captchaInit = true;
    			        	
    		        		var recaptchaSiteKey = "' . $recaptcha_settings['recaptchaSiteKey'] . '";
    		        		
    		        		var goodCaptcha = function(){
    			        		setTimeout(emmaHideCaptcha, 2000);
    		        		}
    					
    						function emmaHideCaptcha() {
    			        		// Unmark our submit button
    			        		// var submitButton = document.getElementById("emma-form-submit-' . $form_unique . '");
    			        		var submitButton = document.getElementsByClassName("activeForm")[0].getElementsByClassName("waiting")[0];
    			        		submitButton.className = "passed-captcha " + submitButton.className.replace( "waiting", "" );
    			        		
    			        		submitButton.click();
    			        	}
    			        	
    			        }
    					
    	        	</script>';

    To this:

    $emma_form .= '<script src="https://www.google.com/recaptcha/api.js" async defer></script>
    <script type="text/javascript">
    if ( typeof captchaExists == "undefined" ) {
    var captchaExists = true;
    } else {
    captchaExists = true;
    }
    if ( typeof captchaInit == "undefined" ) {
    var captchaInit = true;
    var recaptchaSiteKey = "' . $recaptcha_settings['recaptchaSiteKey'] . '";
    var goodCaptcha = function(){
    setTimeout(emmaHideCaptcha, 2000);
    }
    function emmaHideCaptcha() {
    // Unmark our submit button
    // var submitButton = document.getElementById("emma-form-submit-' . $form_unique . '");
    var submitButton = document.getElementsByClassName("activeForm")[0].getElementsByClassName("waiting")[0];
    submitButton.className = "passed-captcha " + submitButton.className.replace( "waiting", "" );
    submitButton.click();
    }
    }
    </script>';

    This seemed to do the trick.
    Though I am sure a better programmer would know how to include that Javascript in a better way. Simply opening this file in a good text editor and auto-formatting it, will ruin it.

Viewing 1 replies (of 1 total)
  • The topic ‘ReCaptcha Errors’ is closed to new replies.