AI要約
説明
wpforms_entry_email_attsフィルターは、通知を送信する前にプログラムでメール通知の属性を変更することを許可します。これは、フォームビルダーで設定するには非現実的な複雑な通知ロジックを管理する場合に特に役立ちます。
パラメーター
- (配列) 件名、メッセージ、その他の設定を含むメール通知の属性。
- $fields
- (配列) フォームフィールドのデータと値。
- $entry
- (配列) エントリデータとメタデータ。
- $form_data
- (配列) 後で利用できるように処理されたフォームの設定/データの配列。
- $notification_id
- (配列) 処理中の現在の通知のID。
このフィルターは、送信される前にプログラムでメール通知の属性を変更することを許可します。これは、国別の通知や複数の受信者のシナリオなど、フォームフィールドの値に基づいた複雑な条件付き通知ロジックを扱う場合に特に価値があります。
$email['subject']を使用してメールの件名にアクセスおよび変更できます。これにより、特定の要件に基づいて件名をプログラムでカスタマイズできます。
例
/**
* Customize email notification attributes.
*
* @link https://wpforms.com/developers/wpforms_entry_email_atts
*
* @param array $email Email notification settings.
* @param array $fields Form fields data.
* @param array $entry Entry data.
* @param array $form_data Form data and settings.
* @param int $notification_id Notification ID.
*
* @return array
*/
function wpf_custom_email_notification( $email, $fields, $entry, $form_data, $notification_id ) {
// Add custom logic here to modify email attributes based on form fields
// Example: Modify subject, recipients, sender info based on country selection
return $email;
}
add_filter( 'wpforms_entry_email_atts', 'wpf_custom_email_notification', 10, 5 );