This article refers to version 1.10.45+ of WS Form PRO.
Spam submissions are a familiar headache for many website owners. Whether you’re running a contact form, a registration process, or a support request form, unwanted content can quickly clog up your inbox and affect the user experience.
At WS Form, we’ve built a variety of spam protection tools to help you stay in control. One of the most effective options is keyword filtering.
This feature lets you block specific words or phrases in form submissions. It is especially useful for catching message-based spam that might otherwise slip past traditional bot-detection methods.
There are three ways of blocking spam by keyword in WS Form:
- Keyword Blocklist setting in Form Settings
- The wsf_submit_block_keywords filter hook
- The Keyword Blocklist add-on
Let’s explore each of these methods:
How to Use the Keyword Blocklist Setting in WS Form
You don’t need to write any code to start blocking keywords. WS Form lets you manage this right from the WordPress admin interface.
To set it up:
- Edit your form in WS Form.
- Click the Form Settings icon at the top of the layout editor.
- Select the Spam tab.
- Check the Enable setting.
- Under Keyword Blocklist, click the + icon to add keywords or phrases.
- (Optional) Add a custom message to show users when a keyword is detected.
Once added, WS Form checks all text based fields in the submission. If a blocked keyword is found, the form will not submit, and an error message will appear on the field where the match occurred.
You can include as many keywords as you need and manage them on a per-form basis.
Smart Matching to Reduce False Positives
Keyword blocking in WS Form is designed to be smart and practical. It won’t flag common or unrelated words that happen to contain a blocked term.
For example, if you block the word “cat,” WS Form will not trigger an error on words like “category” or “catalog.”
It also accounts for punctuation tricks used by spammers, such as:
cat lover
cat.lover
cat(lover)
cat[lover]
This helps ensure you are catching spam without frustrating your users with unnecessary rejections.
Custom Keyword Blocking with a Filter Hook
If you’re a developer or want more advanced control, you can manage keywords using the wsf_submit_block_keywords WordPress filter hook.
This hook lets you define keywords programmatically, either globally or conditionally per form. It is particularly useful if you want to specify a large number of keywords.
Here’s a basic example:
add_filter('wsf_submit_block_keywords', function($keywords, $form, $submit) { // Word matching $keywords[] = 'free trial'; $keywords[] = 'click here'; // String match (Keywords are prefixed with *) $keywords[] = '*seo'; return $keywords; }, 10, 3);
This approach is ideal if you want to pull keywords from a database, enforce consistency across multisite installations, or build logic around what gets blocked.
More on that here:
Customize the Message That’s Shown to Users
Want to personalize the message shown when a keyword is flagged? You can do that using the wsf_submit_block_keywords_message filter hook.
Here’s how:
add_filter('wsf_submit_block_keywords_message', function($message, $form, $submit) { return __('This submission has been blocked due to restricted content.'); }, 10, 3);
This filter hook gets the highest priority when setting a message for keyword blocking. After that if you’ve added a custom message in the Spam tab, that will be used instead of the default invalid feedback configured for a field.
You can use the WS Form variable #keyword
in the message to insert the matching keyword if you wish.
More info:
The Keyword Blocklist Add-On
If you’re using WS Form PRO, another effective way to cut down on spam is with the Keyword Blocklist add-on. This tool scans incoming form submissions for over 1,300 high-signal spam keywords, organized into categories like Adult, Finance, SEO, Sales, and more.
It’s easy to configure—just enable the categories relevant to your needs, and WS Form will automatically block submissions containing those terms. The Adult and Profanity lists are enabled by default, so you get immediate protection without any setup. You can fine-tune the filters as needed, and no coding is required.
The best part? The Keyword Blocklist add-on is free for all WS Form PRO users. If you’re looking for a simple, category-based approach to spam prevention, this is a great option to explore.
Why Block Keywords in WordPress Forms?
While tools like Cloudflare Turnstile, reCAPTCHA, and hCaptcha, help prevent automated bots from submitting forms, keyword filtering focuses on the content users enter.
Here’s why that matters:
- You can block spammy messages that mention things like “buy now” or “http://”
- You can prevent offensive language or inappropriate terms from being submitted
- You can reduce repetitive or copy-pasted support inquiries
- You can filter out phishing or scam phrases
We’ve seen this be particularly helpful for agencies and businesses that deal with high volumes of public-facing form traffic. It gives you an extra layer of protection based on your specific needs.
Combine Keyword Filtering with Other Spam Protection Tools
Keyword filtering works best as part of a multi-layered approach to form security. WS Form supports several other methods to help reduce spam:
Each of these methods targets a different type of spam. When used together, they create a strong defense that covers both bot behavior and user-submitted content.
Real-World Use Cases
Here are some ways we’ve seen keyword blocking used successfully:
- A contact form that blocks references to known scam phrases
- A support form that filters out common spam content like “buy followers”
- A job application form that prevents use of unrelated terms or links
- A feedback form that avoids inappropriate language
Keyword filtering gives you the flexibility to tailor your form protection to your exact audience.
Final Thoughts
If you’re running any type of WordPress form – contact, survey, feedback, or support – it’s worth taking a few minutes to set up keyword blocking.
It’s easy to manage, fully customizable, and works quietly in the background to help ensure the submissions you receive are clean and relevant.
You’ll find everything you need to get started in the WS Form documentation: