flydev Posted March 14, 2018 Author Posted March 14, 2018 Did you checked the browser's console to see if there an error ? Did you call the $modules->get("MarkupGoogleRecaptcha")->getScript() somewhere ? its required.
strandoo Posted March 14, 2018 Posted March 14, 2018 Doh! I had, but not correctly, I guess. Once I echoed '$modules->get("MarkupGoogleRecaptcha")->getScript();', it worked. Thanks for your help. Now I need how the rest of it works. Cheers, Paul 1
Sanyaissues Posted May 13, 2018 Posted May 13, 2018 Hi, @flydev! Recaptcha v3 came out, would you mind taking a look? 3
flydev Posted May 15, 2018 Author Posted May 15, 2018 Hello @Sanyaissues , I was not aware of the reCAPTCHA v3 but it will be definitely implemented. I will wait a bit more documentation as I already tried to get it working but without success. Thanks for your interest ? 2
Jonathan Lahijani Posted September 30, 2018 Posted September 30, 2018 Does this work with FormBuilder? 3 1
flydev Posted October 3, 2018 Author Posted October 3, 2018 On 9/30/2018 at 7:29 PM, Jonathan Lahijani said: Does this work with FormBuilder? That's a good question! When I developed this module I didn't had FormBuilder in hand. Now that I have a copy of this module, I will try to see if it works out of the box tomorrow. Stay tuned ! 1 1
gregory Posted January 22, 2019 Posted January 22, 2019 Hi @flydev, have you got to test it with Form Builder? Thank You. 1
flydev Posted January 23, 2019 Author Posted January 23, 2019 @gregory @Jonathan Lahijani I tested it (but not with all the Custom Embed option), it works with the Custom Embed options C and D. Use the following hook : <?php namespace ProcessWire; // the captcha module $captcha = $this->modules->get("MarkupGoogleRecaptcha"); // hook FormBuilder $forms->addHookBefore('FormBuilderProcessor::renderReady', function ($e) use ($captcha) { $form = $e->arguments(0); // do some custom check here ... if ($captcha->data_recaptcha_type === 'invisible') { // invisible captcha $captcha->render($form); $f = $this->modules->get("InputfieldHidden"); $f->attr('id+name', 'login_submit'); $f->value = 'login_submit'; $form->append($f); } else { // recaptcha v2 $f = $this->modules->get("InputfieldMarkup"); $f->value = $captcha->render(); foreach ($form->children as $field) { if ($field instanceof InputfieldSubmit) { // find the submit button $form->insertBefore($f, $field); // insert reCAPTCHA before the submit button } } } }); I will test later to see if it's possible to embed the captcha into an IFrame. 2
jimmytricks Posted April 25, 2019 Posted April 25, 2019 Great Module, thanks. I had some luck getting this to integrate with FormBuilder (method d) by using the following Form Builder hook to check the recaptcha before submitting: $forms->addHookBefore('FormBuilderProcessor::processInputDone', function ($e) use ($captcha) { $form = $e->arguments(0); // retrieve argument by number (zero based) // Check to see if recaptcha is true if ($captcha->verifyResponse() === true) { // This will process the form as usual } else { // This will cause an error on form and stop processing $form->error('Recaptcha is missing. Please tick I\'m not a robot and try again'); } }); More info on FormBuilder hooks: https://processwire.com/blog/posts/formbuilder-v34/ Cheers, 2
jimmytricks Posted April 29, 2019 Posted April 29, 2019 @Autofahrn For me it shows: Sorry, we can't show this content because you do not have permission to see it. Do I need to do something to see it? Cheers
Autofahrn Posted May 1, 2019 Posted May 1, 2019 @jimmytricks, that post is in FormBuilder support section, as an owner of FormBuilder you should have access to it. 1
iNoize Posted July 22, 2019 Posted July 22, 2019 On 7/9/2016 at 11:45 AM, flydev said: $captcha = $modules->get("MarkupGoogleRecaptcha"); // if submitted check response if ($captcha->verifyResponse() === true) { $out .= "Hi " . $input->post["name"] . ", thanks for submitting the form!"; } else { $out .= "<form method='post' action='{$page->url}'>\n" . "\t<input type='text' name='name'>\n" . $captcha->render() // render reCaptcha . "\t<input type='submit'>\n" . "</form>\n"; $out .= $captcha->getScript(); } echo $out; Hello, can anyone sho thw right example ? The one with plain HTML doesnt work. And i really dont understand why ?? Parse Error: syntax error, unexpected '}' (line 26 of /usr/www/xxxxx/site/templates/contact.php)
flydev Posted July 22, 2019 Author Posted July 22, 2019 (edited) hi @iNoize Looking at the error and the corresponding line (26) pointing to an empty line, I bet that you have some unwanted char in the code caused by the copy/pasta from the forum. Try to open your file (contact.php) with another editor and clean weird chars. The plain HTML code should work as is. Please have a read to those post : If you still have an issue, ping me, I will check your templates. Edited July 22, 2019 by flydev Related Links
KarlvonKarton Posted July 29, 2019 Posted July 29, 2019 I use the module regularly on sites (with Pw form API), but for the first time I needed to implement the module in a plain HTML form, but without any luck. render() will not render anything and the getScript() does not add the script at the bottom of my form. Does plain HTML still work?
flydev Posted July 29, 2019 Author Posted July 29, 2019 Hi @KarlvonKarton thanks for reporting it. Can you tell me on which version of ProcessWire the module didn't work for you ? 1
KarlvonKarton Posted July 29, 2019 Posted July 29, 2019 1 hour ago, flydev said: Hi @KarlvonKarton thanks for reporting it. Can you tell me on which version of ProcessWire the module didn't work for you ? I did the same mistake as someone here above... I did not echo the render() nor the getScript() ... (my form is in plain HTML and not in a var called $out, therefrom...) It's working now. ;-) 1
JFn Posted October 1, 2019 Posted October 1, 2019 (edited) @flydev Great module. It would be nice to have/force a different language or multi-language support. Right now Google renders the widget in what it thinks is you native language. For me that's Dutch, although the html lang="en", the site's default language and my browser is in English as well. This could be done via a simple extra parameter in your module's getScript() and a "hl=langcode" setting, ie.: <script src='https://www.google.com/recaptcha/api.js?hl=en'></script> There's a list at https://developers.google.com/recaptcha/docs/language Edit 1: Already figured out you can do this via the ->render("","en") method. Edit 2: Somehow that's not working. But I expect it's Google's fault. It renders "en" but still displays it in Dutch. Edit 3: It was Google's fault. When you're logged in with your Google account in Chrome (aka 'sync') it will take the language of that account, no matter what language you asked the widget to be. Google always knows better™ ? Edited October 1, 2019 by JFn Solved 1
abdulqayyum Posted November 5, 2019 Posted November 5, 2019 Hello, anyone can tell me how to "Markup Google reCAPTCHA" this module use with "LoginRegister" module. if any one know please suggest me how i use it. Thanks AbdulQayyum.
flydev Posted November 5, 2019 Author Posted November 5, 2019 1 hour ago, abdulqayyum said: Hello, anyone can tell me how to "Markup Google reCAPTCHA" this module use with "LoginRegister" module. if any one know please suggest me how i use it. Thanks AbdulQayyum. Hi Abdul, The solution is already in this thread ?
Ralf Posted April 28, 2020 Posted April 28, 2020 Dear All and @flydev ?? i am currently creating a contact form and wanted to use the Google recaptcha for this. While implementing, I come across the following problem that I can not get solved... My page code structure looks something like this: <?php namespace ProcessWire; ?> <div id='content-body'> <div class='uk-grid' data-uk-grid> <div id='content' class='uk-width-1-2@m'> <?=page()->body?> </div> <div id='contactform' class='uk-width-1-2@m'> <h3>Contact Form</h3> <?php // Google reCaptcha as Modul $captcha = $modules->get("MarkupGoogleRecaptcha"); ...... // form was submitted so we process the form if($input->post->submit) { // Do cool stuff here <<<<-------- I cannot get in here } ?> <form class="uk-form-stacked" action="./" method="post"> <div class="uk-margin"> <label class="uk-form-label" for="name">Your Name <span class='uk-text-danger'>*</span></label> <div class="uk-form-controls"> <input type="text" name="name" class="uk-input" value="<?php echo $name?>" placeholder="Your Name here"> </div> </div> <div class="uk-margin"> <label class="uk-form-label" for="email">Your Email-Adress <span class='uk-text-danger'>*</span></label> <div class="uk-form-controls"> <input type="email" name="email" class="uk-input" value="<?php echo $email?>" placeholder="Email-Adress"> </div> </div> .... <div> <!-- Google reCaptcha code START --> <?php echo $captcha->render()?> <!-- Google reCaptcha code END --> </div> <div class="uk-margin"> <input type="submit" name="submit" class="uk-button uk-button-default" value="Submit"> </div> </form> <?php echo $captcha->getScript(); ?> </div> </div> </div> My problem is now, as soon as I insert this line of code "<?php echo $captcha->getScript(); ?>" on the page like this, my query "if($input->post->submit)" does NOT work anymore .... HELP what is wrong here or where is my mistake? Thanks Ralf
flydev Posted April 30, 2020 Author Posted April 30, 2020 Hi @Ralf, sorry for the delay. Instead of checking for the $input->post->submit, you should check if the response from the ReCaptcha is green. So, instead of : // form was submitted so we process the form if($input->post->submit) { // Do cool stuff here <<<<-------- I cannot get in here } Do : // form was submitted so we process the form if($captcha->verifyResponse() === true) { // Do cool stuff here <<<<-------- you will get here now } Also, try to call the getScript() method on the end of your main markup page. I mean, just before the </body></html> tags. And to avoid calling the module every page request, you can for exemple, check if the current page's template is the contact one and then call the module's getScript() method : <html> <head> </head> <body> ... <!-- other tiers scripts exemple --> <script src="jquery.js"></script> <script src="anotherscript.js"></script> <?php if($page->template->name === 'contact-tpl') { // google recaptcha required script echo $modules->get("MarkupGoogleRecaptcha")->getScript(); } ?> </body> </html> Ping me if you need further help. 2
froot Posted May 2, 2021 Posted May 2, 2021 reCaptcha v2 invisible doesn't seem to be working (or what am I to expect? I've never seen an example for the invisible version anyway – kind of ironic, I know). I had reCaptcha v2 (the regular one) working just fine. Now that I want to change it to invisible I… added a new site-project in the reCaptcha-settings on google.com selected "invisible" in this module's settings and entered the newly created site key and secret key in this module's settings as well as in the div-attribute on the template. refreshed the page (cleared cookies and cache just to be save) but I see no change whatsoever. Thoughts?
PWaddict Posted May 20, 2021 Posted May 20, 2021 Hi @flydev ?? I just installed the module and I'm getting this PHP Notice: Notice: Undefined index: data_badge in C:\laragon\www\mysite\site\assets\cache\FileCompiler\site\modules\MarkupGoogleRecaptcha\MarkupGoogleRecaptcha.module on line 269 Replacing the 269 line with this, fixes the issue: if(isset($data['data_badge'])) $f->attr('value', $data['data_badge']); 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now