FormIt Filter Out or Block Spam Words From Message Field

So very disappointed I couldnt do anything with this 5 year old post in the old forums but its an important update. MODS feel free to add this to the old one or whatever but I wrote an old post with the same title and topic and form what I see that code no longer works…

Well a much smarter friend of mine made this small change and it works and works much better to achieve the goal.

Just create a snippet called “scumwords” with the below content and add that name into your hooks on your formit call. He says it automatically will add plural versions and is not case sensitive too!

Check it out! Hope it helps someone.

<?php
$scumwords = array(
    'website',
    'traffic',
    'eric',
    'Eric',
    'seo',
    'SEO',
    'visitors',
);
 
$message = $hook->getValue('message');

   
foreach ($scumwords as $scumword) {
 
    if (stripos($message, $scumword) !== false) {
        return false;
    }
     
};

return true;
1 Like

Thanks for the contribution. :slight_smile: