Extension

Archived
Forum
(read-only)

Snaptcha

ExpressionEngine 2, ExpressionEngine 3, ExpressionEngine 4, ExpressionEngine 5, ExpressionEngine 6

Back to this add-on's main page
View Other Add-ons From Brian Litzinger

     

Mailing List Form revisited

Support (Resolved)

Darin
Darin

Can legacy Snaptcha 1.7.6 now be used with EE2’s mailing list form by including {exp:snaptcha:field} in the form?

If so, where do I put the validation code shown in the developer docs?

PutYourLightsOn
# 1
PutYourLightsOn

If you wanted to alter the core Mailing List module file, you could insert code to validate a submission which had used {exp:snaptcha:field}, yes. You’d want to insert the validation code inside the insert_new_email() method of the Mailing List module, somewhere in the “error trapping” portion of the code, so you could add to the array of errors in the case that the validation failed.

Darin
# 2
Darin

Once I figured out that I still had to test the submission against Snaptcha’s validation, it worked great. Thank you!

For anyone who is interested, here’s the code I inserted at line 159 of system/expressionengine/modules/mailinglist/mod.mailinglist.php (EE 2.11.7)

require_once PATH_THIRD.'snaptcha/ext.snaptcha'.EXT;
$Snaptcha = new Snaptcha_ext();
$validated $Snaptcha->snaptcha_validate();   // returns a boolean (true or false)
if ( ! $validated)
{
 $errors[] 
$Snaptcha->settings['error_message'];
PutYourLightsOn
# 3
PutYourLightsOn

Excellent, glad you sorted that out Darin.