youngbuckscrew Posted March 22, 2018 Report Posted March 22, 2018 Okay this is one way of upgrading to v2 of recaptcha. Go here https://github.com/google/recaptcha and scroll down to Direct Download (assuming you don't use composer) and download the package. Once downloaded insert it into: core/lib/recaptcha-master Once you have done this go to core/modules/registration/registration.php # Replace or comment out require_once CORE_LIB_PATH.'/recaptcha/recaptchalib.php'; # With require_once CORE_LIB_PATH.'/recaptcha-master/src/autoload.php'; In that same file, scroll down to VerifyData # Replace all code relating to captcha check with // start the error array as false, we dont have any errors yet. $error = false; // set the configurations for the service to work. $secret = Config::Get('RECAPTCHA_PRIVATE_KEY'); $remoteIp = $_SERVER["REMOTE_ADDR"]; $gRecaptchaResponse = $_POST['g-recaptcha-response']; $recaptcha = new \ReCaptcha\ReCaptcha($secret); // Call the google service and verify the answer provided. $resp = $recaptcha->verify($gRecaptchaResponse, $remoteIp); // If Response was a success if ($resp->isSuccess()) { // No errors; continue $this->set('captcha_error', ''); } else { // Set error as true and show error on front-end $error = true; $this->set('captcha_error', true); } And finally on your registration_mainform.tpl <div class="g-recaptcha" data-sitekey="<?php echo Config::Get('RECAPTCHA_PUBLIC_KEY'); ?>"></div> <script type="text/javascript" src="https://www.google.com/recaptcha/api.js?hl=en"> </script> <!-- Recaptcha V2 --> <?php if($captcha_error == true) echo '<p class="error">Please verify you are human!</p>'; ?> you can make a function for that like v1 but that's up to you. Let me know if this helps you! Quote
Administrators Nabeel Posted March 23, 2018 Administrators Report Posted March 23, 2018 Thanks for this, I split it out of the other topic and pinned it. Quote
youngbuckscrew Posted March 23, 2018 Author Report Posted March 23, 2018 No problem! I been following your repo on github! great work you are doing. Im happy to help anyway i can. Quote
jbinner Posted April 18, 2018 Report Posted April 18, 2018 I tried to follow this fix, but it doesn't work, or more likely I am making the edits wrong. You talk about "then scroll down to the "VerifyData" section, but there is 2 sections I see for that and when I make the edits it breaks the reg pages. Can you write this how-to more clearly please? Show exactly what and where? Quote
nfinger Posted April 24, 2018 Report Posted April 24, 2018 (edited) where do you add the site key? see attached screenshot for my error. data-sitekey="your_site_key" captchaerror.zip Edited April 24, 2018 by nfinger add file Quote
Mariano Posted April 26, 2018 Report Posted April 26, 2018 I'm getting the same problems as jbinner, it just makes my registration page break (yay for website backups I guess). Quote
Administrators Nabeel Posted May 15, 2018 Administrators Report Posted May 15, 2018 Split the other changes into a new topic: Quote
mboddicker Posted May 15, 2018 Report Posted May 15, 2018 Nabeel, Thanks for all your help. I did get it working finally. I copied and pasted stuff over but after recopying and pasting the data a second time it started working. So I guess the lesson here is that if you are using a Skin then you may need to modify a file in a different location. 1 Quote
coldpll Posted May 23, 2018 Report Posted May 23, 2018 (edited) DEL! Edited May 24, 2018 by coldpll Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.