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.

Advanced Merge Tagsv1.7.1

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

Read more