Documentation

gwp_censor

The gwp_censor Merge Tag modifier censors disallowed words in a string using either a specified character or a fixed-length string.

Options

mask_char (optional, default = ‘*’)The character used to replace each letter in the disallowed words.
mask_string (optional)A fixed string that replaces the entire disallowed word. If provided, this option takes precedence over mask_char.
ignore_case (optional, default = ‘true’)Determines if the word matching should ignore case. Set to false to make it case-sensitive.
partial (optional, default = ‘false’)
Set to true to partially mask the word. This leaves the first and the last letter visible.

Setup the disallowed words list

To set up the blacklist within the WordPress admin area, follow these steps:

  1. Navigate to Settings: Go to the settings section where you can configure various WordPress options. Typically, the blacklist or disallowed keys are configured under “Discussion” settings, but this might vary based on your theme or plugins.
  2. Disallowed Keys Option: Look for an option labeled similar to “Disallowed Comment Keys,” which allows you to input words or phrases that should be blocked from comments and content. You can add multiple terms by separating them with new line breaks.
  3. Save Changes: After entering the desired terms, make sure to save the changes to update the configuration.
Screenshot of the Disallowed Keys setting in wp-admin.

Examples

{Textfield:1:gwp_censor mask_char='#'}

Censors all disallowed words using ‘#’ to replace each letter.


{Textfield:1:gwp_censor mask_string='CENSORED'}

Replaces each disallowed word with the string “CENSORED”.


{Textfield:1:gwp_censor mask_char='*' ignore_case='false'}

Censors disallowed words using ‘*’, considering case-sensitivity during matching.

Frequently Asked Questions

How do I automatically censor certain words in my form output?

You can use the gwp_censor merge tag modifier to automatically hide or replace disallowed words from your form output. These disallowed words are defined in WordPress → Settings → Discussion → Disallowed Comment Keys. The modifier supports masking with a character, replacing with a string, enabling case sensitivity, and partial masking.

{Comment:7:gwp_censor}

How do I replace each letter of a bad word with a custom character?

You can change the default * mask character by using the mask_char option. For example, to replace every letter with #:

{Comment:7:gwp_censor mask_char="#"}

How do I replace the entire bad word with a full string?

You can use the mask_string option to replace the whole bad word with a custom string. This overrides mask_char.

{Comment:7:gwp_censor mask_string="CENSORED"}

How do I make the word matching case sensitive?

By default, gwp_censor ignores case (so Bad, BAD, and bad are all matched). You can disable this by setting ignore_case=’false’.

{Comment:7:gwp_censor mask_char="*" ignore_case="false"}

How do I show the first and last letter of the bad word, and mask only the middle part?

Set partial=”true” to show the first and last letters of the bad word, masking only the characters in between.

{Comment:7:gwp_censor partial="true"}

Last updated: 18-07-2025

Advanced Merge Tagsv1.9.3

To use the functionalities described in this documentation, you'll need to get the GravityWP - Advanced Merge Tags add-on.

Read more