Skip to content

Magento 1 module which adds the Invisible ReCaptcha in some pages.

License

Notifications You must be signed in to change notification settings

monsieurbiz/Mbiz_InvisibleCaptcha

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mbiz_InvisibleCaptcha

This module adds the Invisible ReCaptcha from Google in all pages and setup the captcha only for the contact page.

Adding the JS in all pages is not a choice we made just because it's simple. It's also because most of the time you'll want to add the captcha in newsletter form and so on.

Requirements

You need to get an API key from Google: https://www.google.com/recaptcha/admin

PHP >= 5.4

How it works

You can setup the API key in the admin panel: System > Configuration > General > Invisible Captcha

In that page you can set your site details and of course you can disable completely the captcha.

You can also choose if you want it by default to be on some pages.

Setup on my own form

It's easy.

Given the following example:

<form method="post">
    <label>
        My Content
        <input type="text" name="content" />
    </label>
    <button type="submit">Send</button>
</form>

You just have to make few changes (only additions):

+<?php
+$_recaptcha = $this->helper('mbiz_invisiblecaptcha');
+?>
+
-<form method="post" id="myForm">
+<form method="post" id="myForm"
+    <?php if ($_recaptcha->isActive()): ?>
+        onsubmit="return captchaMyForm.uiSubmit('<?php echo $_recaptcha->getSiteKey(); ?>', onCaptchaMyFormSubmit, '#g-recaptcha-myform');"
+    <?php endif; ?>
+>
     <label>
         My Content
         <input type="text" name="content" />
     </label>
     <button type="submit">Send</button>
+
+    <?php if ($_recaptcha->isActive()): ?>
+        <div class="g-recaptcha" id="g-recaptcha-myform"></div>
+    <?php endif; ?>
+
 </form>
+
+<?php if ($_recaptcha->isActive()): ?>
+    <script type="text/javascript">
+        //<![CDATA[
+        var captchaMyForm = new MbizInvisibleRecaptchaForm('myForm', true);
+        var onCaptchaMyFormSubmit = captchaMyForm.onSubmit.bind(captchaMyForm);
+        //]]>
+    </script>
+<?php endif; ?>

License

See the LICENSE file.

Contributors

About

Magento 1 module which adds the Invisible ReCaptcha in some pages.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •