Skip Navigation

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

This thread is resolved. Here is a description of the problem and solution.

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 6 years, 7 months ago. 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.

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)

This topic contains 4 replies, has 2 voices.

Last updated by leilaG 6 years, 7 months ago.

Assisted by: Minesh.

Author
Posts
#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

Languages: English (English )

Timezone: 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

Languages: English (English )

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

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

#855198

Of Course 🙂 Thanks again