Buy Now
Sign in

How to prevent form from sending mail after antispam validation

chronenigma , June 12 at 18:03
C
chronenigma
Hello, I use this spam-blocker validation:
https://www.chronoengine.com/faqs/70-chronoforms/cfv5/5285-how-can-i-add-a-spam-blocker-validation
It works fine, but after validation the form nonetheless is sending the message.
I would really appreciate your help.
Best, Jens
GreyHead
Hi Jens,
The Event Switcher action needs to be before the Email action for this to work.
Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
C
chronenigma
Hello Bob,
many thanks for your quick response. You are right, that's it.
I know, if this is not a PHP lesson, but concerning this line:
$result = $filter->check_text($form->data['questions']);
Is it possible to validate more than one field?
Sorry for that.
Best, Jens
GreyHead
Hi Jens,
You can add an array of input names and then loop through that array at the $results line:
. . .​
​$check_these = array ( 'name', 'email', . . .);​
​foreach ( $check_these as $v ) {​
​ if ( $result ) {​
​ // Result contains the matched word (not the matched regular expression)​
​ echo "<p>There is a special place in hell reserved for people who post about '{$result}' on my form!</p>";​
​ return 'spam';​
​ }​
​}​
​. . .
You can change the if part to do whatever you need to happen when spam is found.
Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much