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:

# 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;
    });
  
  }
}
Last Updated: 11/23/2023, 10:32:53 PM