Gravity Forms Filter out Spam by Keywords

A client of mine was beginning to get a ton of spam through their contact form on their website and it seemed to be manual submissions because Captcha and other antispam bot efforts were not working.  Many of the spam entries were for SEO services or other web related marketing tactics.  One thing I noticed was that there were consistent keywords being used in these solicitations and I though if I could block those keywords I could prevent alot of the spam coming through the site.

Gravity Forms  for WordPress has all sorts of great addons both free and paid however this sort of keyword filtering is not an addon I could find.  I did some Google searches and came across a great post detailing how to accomplish exactly what I wanted. The only downside to this is you need access to your functions.php file and it cannot be implemented through a plugin.  Maybe soon someone will take this on as a plugin but until then here is how to accomplish this:

To add your keywords to the code just replace the words in the section called $stop_words with your own.

Thank you to http://www.blueliquiddesigns.com.au/ for this awesome bit of code.[/fusion_builder_column][/fusion_builder_row][/fusion_builder_container]

By |September 26th, 2014|Snippets, Wordpress|3 Comments

3 Comments

  1. David Smith September 28, 2014 at 1:05 am - Reply

    Hey Chris, definitely a handy snippet.

    If you’re looking for a plugin + UI to handle this, check out GP Comment Blacklist (part of Gravity Perks). A lot of users don’t know that WordPress offers a setting to specify a list of blacklisted words for your WordPress comments. It’s called the Comment Blacklist (available via the WordPress admin menu under Settings -> Discussion). You can add a lot of power to this setting with this unofficial list of recommended blacklist words:

    https://github.com/splorp/wordpress-comment-blacklist

    Combine that with GP Comment Blacklist, and you can extend that same blacklist validation from your WP comments to your Gravity Forms.

    If a UI isn’t important to you, you could apply that same list of blacklist words to your current snippet.

    Thanks for sharing. 🙂

    • Chris Moore September 29, 2014 at 2:15 pm - Reply

      Thanks for the great tip, David! I will definitely have to check out Gravity Perks as well.

  2. J January 6, 2017 at 9:37 am - Reply

    Hi,

    If you hit submit, this snippet works and gives you an error message when a word/phrase triggers the spam filter.

    However, if you just click submit again, the form will submit even with the word/phrase triggers still in the message/form field(s).

    Any idea how to fix?

Leave A Comment