Captchas
Captchas enable you to add additional methods to protect your form from Spam.
# Captcha Class
See examples of how to build your Captcha Class from the default Captchas in Sprout Forms:
- Duplicate Submission Captcha (opens new window)
- Javascript Captcha (opens new window)
- Honeypot Captcha (opens new window)
- Google Recaptcha for Sprout Forms (opens new window)
# Register Event
Once you have created your Custom Captcha, register your Captcha class with Sprout Forms to display your Captcha in the Spam Protection settings and enable it for your forms.
namespace mycompany\mycaptchaplugin;
use mycompany\myplugin\integrations\sproutforms\captchas\MyCaptcha;
use barrelstrength\sproutforms\services\Forms;
use yii\base\Event;
class MyCaptchaPlugin extends Plugin
{
public function init()
{
parent::init();
Event::on(Forms::class, Forms::EVENT_REGISTER_CAPTCHAS, function(Event $event) {
$event->types[] = MyCaptcha::class;
});
}
}