Closed MedusaDelft closed 5 years ago
Hi @medusadelft
The README has details on how to use RecaptchaV2 with FormIt: https://github.com/sepiariver/recaptchav2/blob/master/README.md#usage-examples
A couple of notes from your posted code:
I’m guessing the main issue here is the lack of the required hook.
Sorry @MedusaDelft I just noticed you mentioned you had tried it with the hook in place. What is the Snippet with ID 37 please? And also what is on line 114 of that Snippet?
Yes, I have tried it with the hook in place. I forgot to add it, as I removed it so the form is working again. The backticks I removed.
ID 37 (37.include) starts with:
<?php
/**
* recaptchav3 hook for use with MODX form processors
*
* Based on https://github.com/google/recaptcha
*
* @copyright Copyright (c) 2014, Google Inc.
* @link http://www.google.com/recaptcha
*
* Ported to MODX by YJ Tso @sepiariver
*
Line 114 is the foreach:
// Hook pass/fail
if ($resp != null && $resp->isSuccess()) {
return true;
} else {
$msg = '';
if ($props['display_resp_errors']) {
foreach ($resp->getErrorCodes() as $error) {
$msg .= $error . "\n";
}
}
if (empty($msg)) $msg = $recaptcha_err_msg;
$hook->addError('recaptchav3_error', $msg);
$modx->log(modX::LOG_LEVEL_DEBUG, print_r($resp, true));
return false;
}
Sorry for the confiusion I caused with the missing hook in the formit snippet.
Thanks @medusadelft that was very helpful. I’ve updated the Snippet here: https://github.com/sepiariver/recaptchav2/blob/master/core/components/recaptchav2/elements/snippets/recaptchav3.snippet.php
Would you mind please trying the new code in the Snippet ID 37?
Note: I think you are getting a null or otherwise invalid response from Recaptcha. This fix shouldn’t change that, but will prevent the horrible server error when it happens.
Hi,
I have installed ModX 2.6.5 with FormIt 4.2.3 and ReCaptchaV2 3.1.0-rc on Apache/php 7.2.
When I add recaptchav3 to the FormIt-hook, I get various errors in my server-log and the response of the server is: Error 500 - Unable to process request. I upgraded ModX to 2.7.1, same problem. In the log-file I see (I removed the domain name):
It looks like problems with various function calls. Array's passed, functions not available that are expected The site is pretty basic. About 15 plugins.
The snippet:
I also have a similar problem on another site. I do get the response page, but the recaptchav3 seems to be ignored.
So I guess RecaptchaV2 and FormIt don't work together pretty good or I am doing something wrong. If so, please point me in the right direction. If you need more information, please let me know.