thoughtfully/module-recaptcha 0.0.2

Google Recaptcha integration for Magento 2

Type

magento2-module

License

None

Requires

None

Requires (dev)

None

Suggests

None

Provides

None

Conflicts

None

Replaces

None

Magento 2 - Google Recaptcha

This module adds Google Recaptcha integration with Magento 2 forms.

Installation

Require module with composer.

composer require thoughtfully/module-recaptcha

Upgrade and recompile Magento

php bin/magento setup:upgrade
php bin/magento setup:di:compile

Configuration

The module configuration can be found by logging into the Magento 2 administration panel and navigating to:

Stores > Settings > Configuration > Thoughtfully > Recaptcha

General

  • Enable
    • Enable or disable Google Recaptcha validation
  • API URL
  • Site Key
    • The site key provided when setting up a Google Recaptcha key pair in the Recaptcha Admin.
  • Secret Key
    • The secret key provided when setting up a Google Recaptcha key pair in the Recaptcha Admin.

Forms to Validate

  • Contact Form
    • The Magento 2 native contact form located at https://example.com/contact
  • Registration Form
    • The Magento 2 native customer registration form located at https://example.com/customer/account/create

Validate Another Form

Use the following information to implement Google Recaptcha on your own form:

  • Render the module's recaptcha.captcha block (defined in view/frontend/layout/default.xml) within your <form/>.
<?php echo $block->getLayout()->renderElement('recaptcha.captcha') ?>
  • Validate the captcha within the controller.
    • The abstract class file Plugin/AbstractPlugin.php defines the method validateRecaptcha() to validate the user's captcha input.
    • You can utilize a Plugin (Interceptor) to validate a captcha before a form is submitted to a Magento controller endpoint. Refer to Plugin/Controller/ContactFormPlugin.php for an example.

Issues / Enhancements

Please feel free to request features / report issues / give feedback using the repository's issue board.