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

     

Snaptcha with AMP forms

General

tmmedia
tmmedia

Hi there,

I’m creating AMP templates for my blog posts and I had to convert the comment form to an AMP form - which only accepts JSON responses. I was able to get the comment form working by hooking into an extension and outputting JSON if the form is on an AMP page, but I had to disable Snaptcha, because AMP validation was not liking the hidden snaptcha field, since it doesn’t like inline styling or the non-AMP javascript. Any thoughts about an alternative approach to getting this to work?

Thanks,
Kristine

PutYourLightsOn
# 1
PutYourLightsOn

Hi Kristine,
Since Snaptcha relies on Javascript for the medium and high security levels, the only way I see integration on an AMP page being possible is using the low security setting. Obviously this will reduce the effectiveness of the add-on but that is unfortunately the compromise that goes along with forms on AMP pages…
https://www.putyourlightson.net/snaptcha/docs#security_levels
Ben

tmmedia
# 2
tmmedia

I was able to get it to work with Snaptcha set to the Low setting, but ideally I want the rest of my pages to have a High setting, and only override the security setting on my AMP pages. I tried using the {exp:snaptcha:field security_level=“1”} template tag, which correctly creates a snaptcha field at the low security setting, but when it validates, it’s still running it at the extension settings, which is set to High, so it’s never able to validate.

Is there a way to get it to validate at the setting that I have set up for the field somehow?

PutYourLightsOn
# 3
PutYourLightsOn

No, unfortunately that isn’t possible, as it would have security implications. If you must use a form on an AMP page then the only option is the low setting.