Home / Admin / To Remove a Single Field From {all_fields}
Duplicate Snippet

Embed Snippet on Your Site

To Remove a Single Field From {all_fields}

This code snippet removes a single field from your email notifications while still using the {all_fields} smart tag.

<10
Code Preview
php
<?php
/**
 * Remove Specific Fields from Notifications
 *
 * @link https://wpforms.com/developers/how-to-remove-specific-fields-from-notifications
 */
add_action('wpforms_loaded', function() {
    add_filter('wpforms_entry_email_data', function ($fields, $entry, $form_data) {
        // Bail early if form ID is not equal to 1000
        if ((int)$form_data['id'] !== 1000) {
            return $fields;
        }
 
        // Unset field from notifications with field ID #3
        if (isset($fields[3])) {
            unset($fields[3]);
        }
 
        return $fields;
    }, 11, 3);
});

Comments

Add a Comment