Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reCaptcha not stopping a form from sending? #14

Open
bleuchill opened this issue Aug 30, 2018 · 5 comments
Open

reCaptcha not stopping a form from sending? #14

bleuchill opened this issue Aug 30, 2018 · 5 comments

Comments

@bleuchill
Copy link

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?

@bgarrant
Copy link

bgarrant commented Sep 1, 2018

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?

@eheiser
Copy link

eheiser commented Jan 7, 2019

Same issues here, anyone ever got this to work?

@theurbanu
Copy link

Same here

@brandondeweese
Copy link

Same.

@xhuang9
Copy link

xhuang9 commented Dec 18, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants