Snaptcha (Simple Non-obtrusive Automated Public Turing test to tell Computers and Humans Apart) is an invisible captcha and will be the last time you will ever have to think about protecting your forms from spam bots.

Snaptcha automatically validates your forms on submission, ensuring that spam bots are not able to submit forms on your site.

To use Snaptcha, first install the plugin and then go to the plugin settings page. Snaptcha validation is disabled by default so that you can first add the required template tag to your forms. Once you have done this you can enable Snaptcha validation.

Snaptcha

Template Tags

Add the following tag inside your form tags:

{{ craft.snaptcha.field }}

Validation

Snaptcha validation works with the following plugins out-of-the-box. If you would like us to add support for any other plugins then just let us know and we would be happy to.

If you use the Sprout Forms displayForm() template tag to output your form then Snaptcha will automatically add the field to the form.

Settings

Snaptcha Validation Enabled
Whether Snaptcha should validate form submissions on the site

One Time Key
Whether Snaptcha should limit to a single form submission per page refresh (recommended for low to medium tr sites)

Expiration Time
The expiration time for form submission in minutes

Refresh Rate
The refresh rate of the Snaptcha value in minutes (only applies with One Time Key disabled)

Minimum Submit Time
The minimum time for form submission in seconds (increase this to harden spam blocking)

Field Name
The name of the hidden Snaptcha input field

Error Message
The error message that will be displayed if Snaptcha identifies a submission as spam

Blacklist
IP addresses to blacklist from all form submissions (one per line)

AJAX Forms

If your forms use AJAX to submit data then you must ensure that the Snaptcha field and its corresponding value is submitted as well.

Log

The Snaptcha log displays the number of form submissions that were approved and denied by Snaptcha, as well as a graph over time.

Testing Snaptcha

If you want to test or see how Snaptcha works on your site then navigate to one of your forms, open your browser's inspector and delete the input field that Snaptcha inserted. It will usually be inside your form's markup and will have an id that begins with the prefix in your extension settings ("snap" by default). After deleting the input field, submit the form and the error message from your extension settings should appear. 

Developers

Developers can easily add Snaptcha fields and validation to plugins. Create a field using Snaptcha's getField function:

$field = craft()->snaptcha->getField();

Or get a field value using Snaptcha's getFieldValue function:

$value = craft()->snaptcha->getFieldValue();

Validate a form using Snaptcha's validate function:

$validated = craft()->snaptcha->validate();

The function above returns true if validation passed or false if it failed. To have Snaptcha output an error to the browser you can call the function as follows:

craft()->snaptcha->validate(true);

Events

Snaptcha provides events to alert plugins when things are happening:

snaptcha.onBeforeValidate
Raised before validation occurs. You can prevent validation from happening by setting $event->performAction to false.

snaptcha.onAfterValidate
Raised after successful validation occurs.

Support

Email support available at [email protected]