Skip Navigation

[Gelöst] Notifications – Sender email (generic field) for Multiple form ID’s

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

Problem:
How to add hook for multiple CRED form IDs.

Solution:
you should try to use following code where you can check multiple form IDs using in_array() function.

You can find proposed solution, in this case, with the following reply:
https://toolset.com/forums/topic/notifications-sender-email-generic-field-for-multiple-form-ids/#post-811086

Relevant Documentation:

This support ticket is created vor 6 Jahren, 7 Monaten. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

Dieses Thema enthält 4 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von leilaG vor 6 Jahren, 7 Monaten.

Assistiert von: Minesh.

Author
Artikel
#810784

We are using the below code for 1 form ID, is it possible to add multiple form ID's to this function?

function customise_cred_notifications( $headers, $formid, $postid, $notification_name, $notification_number ) {
if( $formid == 17097 ) {
$sender_email = $_REQUEST['Email'];
$sender_name = $_REQUEST['Name'];
$myheaders = array( "From: " . $sender_name . " <" . $sender_email . ">" );
return array_merge($headers, $myheaders);
}
return $headers;
}
add_filter('cred_mail_header', 'customise_cred_notifications', 10, 5);

#811086

Minesh
Supporter

Sprachen: Englisch (English )

Zeitzone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - you should try to use following code where you can check multiple form IDs using in_array() funciton.

function customise_cred_notifications( $headers, $formid, $postid, $notification_name, $notification_number ) {

 $form_ids_array= array(17097 ,9999,222,111);
if (in_array($formid , $form_ids_array)) {

$sender_email = $_REQUEST['Email'];
$sender_name = $_REQUEST['Name'];
$myheaders = array( "From: " . $sender_name . " <" . $sender_email . ">" );
return array_merge($headers, $myheaders);
}
return $headers;
}
add_filter('cred_mail_header', 'customise_cred_notifications', 10, 5);

Where:
- Adjust the $form_ids_array with your original form Ids.

#855147

Amazing! Thank you for your help.

#855168

Minesh
Supporter

Sprachen: Englisch (English )

Zeitzone: Asia/Kolkata (GMT+05:30)

Thank you. would you mind to resolve ticket with happy face 🙂

#855198

Of Course 🙂 Thanks again