| |

How to Send Plain Text Emails in Forminator and Remove Commas from Names

Forminator is a powerful WordPress form plugin that allows you to create custom forms easily. However, by default, Forminator sends email notifications in HTML format, and if a form includes a first and last name field, a comma sometimes appears between them. This can be an issue if you prefer plain text emails or want to remove unnecessary formatting from names.

In this article, we’ll show you how to send Forminator emails as plain text and remove unwanted commas from names using the Code Snippets plugin. This method ensures that your emails remain clean, readable, and free from unnecessary formatting.


Why Use Plain Text Emails in Forminator?

By default, Forminator sends emails in HTML format, which can sometimes cause issues such as:

  • Emails being marked as spam due to excessive formatting.
  • Formatting inconsistencies across different email clients.
  • HTML code cluttering up the email body if plain text is preferred.

Switching to plain text emails ensures that your messages are simple, lightweight, and universally compatible.


How to Force Plain Text Emails and Remove Commas from Names in Forminator

The easiest way to achieve this is by adding a custom code snippet to WordPress. Instead of modifying functions.php, we recommend using the Code Snippets plugin, which allows you to safely add and manage custom code.

Step 1: Install the Code Snippets Plugin

  1. Go to Plugins > Add New in your WordPress dashboard.
  2. Search for Code Snippets and install the plugin.
  3. Activate the plugin.

For a detailed guide, check out this tutorial.

Step 2: Add the Custom Code Snippet

Once the plugin is installed, follow these steps:

  1. Navigate to Snippets > Add New.
  2. Name it “Fix Forminator Emails (Plain Text + No Comma in Name)”.
  3. Copy and paste the following code:
add_filter('forminator_custom_form_mail_admin_message', function($message, $data, $entry, $form_id) {
    foreach ($data as $key => $value) {
        if (is_string($value) && strpos($value, ',') !== false) {
            $data[$key] = str_replace(',', '', $value); // Remove comma from names
        }
    }
    $message = str_replace(',', '', $message); // Remove comma from message
    return wp_strip_all_tags($message); // Convert to plain text
}, 10, 4);

add_filter('forminator_custom_form_mail_user_message', function($message, $data, $entry, $form_id) {
    foreach ($data as $key => $value) {
        if (is_string($value) && strpos($value, ',') !== false) {
            $data[$key] = str_replace(',', '', $value); // Remove comma from names
        }
    }
    $message = str_replace(',', '', $message); // Remove comma from message
    return wp_strip_all_tags($message); // Convert to plain text
}, 10, 4);
  1. Select “Run snippet everywhere”.
  2. Click Save and Activate.
Related  How to Customize the Colors of Twenty Thirteen WordPress Theme

How This Code Works

✅ Forces plain text emails by stripping all HTML tags.
✅ Removes commas from first and last names in form submissions.
✅ Applies to both admin and user notification emails.


Final Thoughts

By using the Code Snippets plugin, you can send Forminator emails as plain text and remove unwanted commas from names, ensuring clean and professional-looking emails. This method is safe, easy to implement, and does not require modifying WordPress core files.

For more details on using the Code Snippets plugin, check out this guide.

Leave a Reply

Your email address will not be published. Required fields are marked *