Extension

Developer
Supported

Snaptcha

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

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

     

You must be logged in to post.

Disable Snaptcha on forms for logged in users

Support (Resolved)

wardour
wardour

We are using freeform lite and Snaptcha.

Works great for the contact form on the front end of the website.

However for the password protected forms we have. There are some issues with submissions that is causing my client some concern.

It’s not clear why these forms are not always submitting, when every submission should be sent.

Really I’d love to disable the plugin for these password protected forms only. How can this be done?

Would appreciate any solutions.

Thanks in advance.

PutYourLightsOn
# 1
Developer
PutYourLightsOn

What type of forms are the password protected forms, and are they in the supported list of forms?

wardour
# 2
wardour

I believe so. We are using:

https://docs.solspace.com/expressionengine/freeform/v2/#key-features

Freeform Lite V2

Does the ‘Lite’ make a difference?

PutYourLightsOn
# 3
Developer
PutYourLightsOn

No, the “Lite” version shouldn’t make a difference. How are you password protecting the forms? I don’t see that as a feature in the Freeform v2 docs.

wardour
# 4
wardour

A user can only access the forms when they are registered and log in to a private area of the site.

PutYourLightsOn
# 5
Developer
PutYourLightsOn

Ah I see. There’s unfortunately no way to disable form validation in Snaptcha on a per form basis. What you could do is manually prevent validation for logged-in users, by adding the condition below to `ext.snaptcha.php`.

public function snaptcha_validate($security_level='')
{
    
// Don't validate if user is logged-in
    
if (ee()->session->userdata('logged_in'))
    
{
        
return TRUE;
    
wardour
# 6
wardour

Thanks that set me off in the right direction.

Initially I tried your code in ee6. No joy but made sense what you were suggesting.

There is not a ‘logged_in’ variable. But a quick search of the source code turned up a check against the member_id variable.

Final working code:

// Don't validate if user is logged-in
if (ee()->session->userdata['member_id'!= 0)
{
    
return TRUE;
PutYourLightsOn
# 7
Developer
PutYourLightsOn

Ah yes, I didn’t test in EE6, glad to hear you got it working!