[Forminator] Filter profanities submitted through a form

One of my clients would like to add a profanity filter to Forminator form. His goal is to not allow the form to be submitted when the content contains banned words. Can that be achieved?

  • Alessandro
    • Nightcrawler & Daydreamer

    Hi there, thanks for using Forminator,

    We created a fix for you, so you can validate form fields against and filter unwanted words.

    You can add the above snippet in a mu-plugin. If you are not familiar with mu-plugins, you can read more about them here:

    https://wpmudev.com/manuals/wpmu-manual-2/using-mu-plugins/

    You can download you plugin here:

    https://gist.github.com/wpmudev-sls/36c0ea01f66c29fb05c4674ebb8b40ff

    By clicking Download ZIP on the upright part, then unzip and upload it to your mu-plugins directory.

    Before upload this snippet, make sure to update the following code to reflect your forms/fields.

    private $fields_to_check = array(
    // User defined - One form per line with selected fields (must exists in forms' settings)
    // Example: $form_id => array('field-1', 'field-2', ..., 'field-n')
    1097 => array( 'textarea-1' )
    );
    private $profanity_filter = array(
    // User defined - One word pre row
    'word1',
    'word2',
    'word3'
    );

    As we do comprehensive tests on our code, sometime we may miss something, if so, report it to assist you further.

    Hope this helps!

    Kind regards!