I’m doing a bit of a non standard implementation of Captch with a contact form (using Freeform).
We get quite a bit of spam via our form, but the nature of it’s implementation makes it very undesirable to use a Captcha. As nearly all our genuine form submissions come from the same country, but all the spam comes from from elsewhere. So I figured a simple fix would be to only display the captcha to visitors from outside the target country.
So in have tried using the Countries plugin to test where the visitor is from then conditionally displaying the captcha as a result:
{if "{exp:country}" == "au"}
{if captcha}
<div class="captcha">
<label>Please enter the word below</label>
<input type="text" name="captcha" value="{captcha_word}" size="20" maxlength="10" class="field" /><br >{captcha}
<input type="hidden" name="captcha_fired" value="yes" />
</div>
{/if}
{/if}Pretty straight forward stuff, with the addition of a hidden field to let me know if captcha was shown for a form submission, so I know if they are defeating the captcha via some means.
But I’m running into issues with the parse order by the looks of it. Using this method, the captcha won’t display if for my target country, but I still get the error saying I needed to complete the captcha on submission.
So my guess is the captcha is parsed prior to the conditional, then when the conditional is parsed, the captcha ui isn’t displayed but EE still expects the input?
Assuming this is the case, anyone got any ideas how I can work around it? Took a bit of a wild stab at putting the captcha in an inbedded template, but as I thought, no joy.
Any help would be appreciated.
Thanks