Achtung!

Dieser Artikel enthält PHP-Code und richtet sich an Entwickler. Wir stellen diesen Code als Service zur Verfügung, bieten jedoch keine Unterstützung für Codeanpassungen oder die Entwicklung durch Dritte.

Für zusätzliche Hilfe siehe das Tutorial von WPBeginner zum Hinzufügen von benutzerdefiniertem Code.

Schließen

Beschreibung

The wpforms_entry_email_data filter applies to entry fields before a form notification email is sent.

Parameter

$fields
(array) Bereinigte Feldwerte/Eigenschaften des Eintrags.
$entry
(array) Original $_POST global.
$form_data
(array) Verarbeitete Formulareinstellungen/Daten, die zur späteren Verwendung vorbereitet sind.

Quelle

wpforms/includes/class-process.php

Weitere Informationen

The wpforms_entry_email_data filter is applied to the form field information used when creating and sending form notifications emails.

This filter can be used to modify the submitted form field details in the notification emails.

Beispiele

Remember to change your form ID from 890 to the form ID that you’re targeting.

/**
 * Filter applies to entry fields before a form notification email is sent.
 *
 * @link  https://wpforms.com/developers/wpforms_entry_email_data/
 *
 * @param  array  $fields     Sanitized entry field values/properties.
 * @param  array  $entry      Original $_POST global.
 * @param  array  $form_data  Form data and settings.
 *
 * @return array 
 */

function wpf_dev_entry_email_data( $fields, $entry, $form_data ) {
     
    // Only run on my form with ID = 890
    if ( absint( $form_data[ 'id']  ) !== 890 ) {
    return $fields;
    }
     
    foreach ( $fields as &$field ) {
 
        if ( empty( $field[ 'value_choice' ] ) ) {
            continue;
        }
         
        // Default is a dash -, change here to what you need.
        $delimiter = ' : ';
        $field[ 'value' ] = $field[ 'value_choice' ] . $delimiter . wpforms_format_amount( $field[ 'amount_raw' ], true );
    }
     
    return $fields;
     
}
add_filter( 'wpforms_entry_email_data' , 'wpf_dev_entry_email_data', 10, 3  );

If you need any help on where to find your form and field IDs, please review this tutorial.

Referenzartikel

How to Change the Payment Delimiter Inside Email Notifications