Bad Words / Profanity Filter
Better Messages includes a server-side bad-words filter that rejects messages containing any term on a configurable banned list. The block happens before the message is delivered — recipients never see it, and the sender gets a clear error message you can customize. Useful for family-friendly communities, paid memberships, support channels, and any site where moderation reduces friction.
What it adds#
- Admin-managed banned-word list (one term per line)
- Case-insensitive matching across the entire message text
- Configurable error message shown to the sender on blocked attempts
- Optional bypass for administrator accounts (or any role you choose)
- Works pre-send — blocked messages never reach the recipient or the database
How it works#
When a user submits a message, the filter walks each entry in the banned-word list and tests it as a word-boundary regex against the message text. If any term matches, the send is rejected and the configured error message is returned. The blocked message is not stored anywhere — there's no trail, no recipient notification, no database record.
| Match scenario | Outcome |
|---|---|
| Message contains an exact banned word as a standalone token | Blocked, error shown |
| Banned word appears inside a larger word (e.g. "ass" inside "class") | Allowed — matching is word-boundary, not substring |
| Word in a different case | Blocked (case-insensitive) |
| Banned word inside an attached file's name | Allowed (only message text is scanned) |
| Sender is an administrator and "Skip admins" is on | Allowed |
If you need substring matching for a specific term, type it with a leading or trailing fragment (e.g. viagra already matches Viagra, viagra! etc., but cialis will not match cialispharma). Multi-word phrases (e.g. click here) also work — the word-boundary regex treats the whole phrase as the token.
When to use#
| Site type | Recommended setup |
|---|---|
| Family / kid-friendly community | Aggressive list, no admin bypass, friendly error message |
| General community / forum | Standard profanity list + competitor brand names |
| Marketplace | Block contact-info attempts: "WhatsApp", "Telegram", external emails, phone formats |
| LMS | Block academic dishonesty terms ("answer key", paid-essay services) |
| Support / commercial | Block spam keywords + common phishing terms |
How to enable#
Navigate to WP Admin → Better Messages → Settings → Restrictions.
- Bad Words List — Enter banned words or phrases, one per line (case doesn't matter)
- Skip for Admins — Let administrator-role accounts bypass the filter
- Bad Words Error Message — Custom message shown to the sender when their message is rejected
Frequently asked questions#
Can I bypass the filter for moderators, not just admins?#
The built-in Skip for Admins toggle covers only the WP administrator capability. For broader bypasses (e.g. a custom Moderator role), filter the rate-limit / restriction errors via better_messages_can_send_message — return true for roles that should be allowed through.
Does the filter run on edited messages?#
Yes — edited messages re-validate against the bad-words list. If an edit introduces a banned word, the edit is rejected and the original text is preserved.
Are message attachments scanned?#
No — only the message text is scanned. Attached file names and contents are not. For images that may contain text, an image moderation service (or AI content moderation on the WebSocket version) is more appropriate.
What happens to a user who keeps trying to send banned words?#
Nothing automatic — each attempt is just rejected with the same error. For tiered escalation (e.g. temp-ban after N attempts), pair this with pre-moderation so a moderator sees the pattern.
How big can the banned-word list be?#
Up to a few hundred entries performs fine. Beyond that, performance starts to drop — every message runs each term through a regex test. Consolidate variants with a single root form when possible.
See also#
- Pre-moderation — admin reviews messages before delivery (stronger than word-based blocking)
- AI content moderation — AI-driven moderation for nuanced content (WebSocket version)
- User-to-user block — let users block each other
- Role-based access — gate messaging entirely by user role