How to prevent form from sending mail after antispam validation

ch chronenigma 12 Jun, 2018
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
Gr GreyHead 14 Jun, 2018
1 Likes
Hi Jens,
​
The Event Switcher action needs to be before the Email action for this to work.
​
Bob
ch chronenigma 15 Jun, 2018
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
Gr GreyHead 16 Jun, 2018
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
This topic is locked and no more replies can be posted.