craft-recaptcha
craft-recaptcha copied to clipboard
reCaptcha not stopping a form from sending?
I was able to install and have reCaptcha show successfully on the footer of a site I'm editing (but did not develop). The form—pixelandtonic's contact form—is meant to get a visitor's name and email address.
However, the form still validates even though I didn't check the reCaptcha panel. I only have {{craft.recaptcha.render('dark', 'compact')}} on the page. I tried to include the saveuser code from the readme, but I don't think it's necessary for what I use the form for.
What am I missing?
How does this work? I am having same issue. Form just submits. I assume we need the server side response object but isn't that part of this plugin?
Same issues here, anyone ever got this to work?
Same here
Same.
Go to craft/plugins/contactform/controllers/ContactFormController.php at line 34 adding:
// required to install craft recaptcha plugin
$captcha = craft()->request->getPost('g-recaptcha-response');
$verified = craft()->recaptcha_verify->verify($captcha);
if(!$verified)
{
//Uh oh...its a robot. Don't process this form!
craft()->userSession->setError('Please check the recaptcha, to prove that you are not a robot!');
$errorMsg = array(
'message' => $message,
'recaptchamessage' => "Please verify your recaptcha"
);
$this->renderTemplate("contact", $errorMsg, true, true);
}
My contact page is {{ siteUrl }}contact
, please change it based on the template you wanted to show.
And the in html/twig, you can do
{% if recaptchamessage is defined %}<div class="errors">{{ recaptchamessage }}</div>{% endif %}
to grab the error.
This is temporary fix, and the important thing is its working. Important notice: if you uninstall plugin recaptcha, and you have contact form running. When you submit the contact form, you will definitely get a 500 error.