Google reCaptcha and Advanced Forms
Permalink
I'm using Concrete5 v5.6.1. I'm also using Advanced Forms. We found that the built-in captcha option is not all that great.
We want to integrate the newer Google reCaptcha with the checkbox option.
I did download recaptchalib for one of the other forum threads, but I found out that this one uses the previous version of reCaptcha. So, we don't want that.
I'm going to download the latest version from github here:https://github.com/google/recaptcha...
Anyone have an idea, some guidance, on how i may implement this into Advanced Forms.
I've been looking around and using the old lib i was able to add it to the form, but its not connected and i'm not sure how to connect the form validation in Concrete5 to add a custom form like this.
I've been able to get the captcha to appear in my webform. So thats good, but how might i override the built-in concrete5 form validation?
I think it is probably something in this bit that i need to change.
I see in the first line it says $fieldName='ccmCaptchaCode'. My google recaptcha isnt in a form field, so how do i target this?
I changed $fieldName='ccmCaptchaCode' to "$fieldName='g-recaptcha-response'", that seemed to allow me to submit the form. When i submit the form, I see a message that says "Incorrect CAPTCHA code. Please try again." I'm not sure where this is coming from, but I guess it is from the built-in CaptchaCode and since i've replaced it with Google reCaptcha, its still looking for the value of the Concrete5 captcha. So, is there a way to disable the form from looking at that?
I thought renaming the captcha.php from /concrete/helpers/validation/ would remove all of that functionality? Guess i was wrong!
We want to integrate the newer Google reCaptcha with the checkbox option.
I did download recaptchalib for one of the other forum threads, but I found out that this one uses the previous version of reCaptcha. So, we don't want that.
I'm going to download the latest version from github here:https://github.com/google/recaptcha...
Anyone have an idea, some guidance, on how i may implement this into Advanced Forms.
I've been looking around and using the old lib i was able to add it to the form, but its not connected and i'm not sure how to connect the form validation in Concrete5 to add a custom form like this.
I've been able to get the captcha to appear in my webform. So thats good, but how might i override the built-in concrete5 form validation?
I think it is probably something in this bit that i need to change.
public function check($fieldName='ccmCaptchaCode') { if ($_POST["g-recaptcha-response"]) { $resp = recaptcha_check_answer ($this->secret, $_SERVER["REMOTE_ADDR"], $_POST["g-recaptcha-response"]); if ($resp->is_valid) return TRUE; } return FALSE; }
I see in the first line it says $fieldName='ccmCaptchaCode'. My google recaptcha isnt in a form field, so how do i target this?
I changed $fieldName='ccmCaptchaCode' to "$fieldName='g-recaptcha-response'", that seemed to allow me to submit the form. When i submit the form, I see a message that says "Incorrect CAPTCHA code. Please try again." I'm not sure where this is coming from, but I guess it is from the built-in CaptchaCode and since i've replaced it with Google reCaptcha, its still looking for the value of the Concrete5 captcha. So, is there a way to disable the form from looking at that?
I thought renaming the captcha.php from /concrete/helpers/validation/ would remove all of that functionality? Guess i was wrong!
This is a bit outdated now, but if it helps there is an addon for simple reCAPTCHA.
https://www.concrete5.org/marketplace/addons/recaptcha...
https://www.concrete5.org/marketplace/addons/recaptcha...
But wait there was more that i needed to do. I did do an override for /helpers/validation/
I added a captcha.php and recaptcha.functions.php file.
I had to update the recaptcha_check_answer function to this:
So now i am getting the TRUE/FALSE response that i needed from this function to make the first part work. Before I was always getting an error when i submitted the form even if i had checked the google reCaptcha box.