Problem: I have a CRED form that captures name and email address using generic fields. I would like to set the "From" email address using these generic field values.
Solution: There is no easy way to do this in the wp-admin area, so just leave the sender information fields empty. To manipulate the sender's email address, you must use the CRED API to modify the email headers:
function customise_cred_notifications( $headers, $formid, $postid, $notification_name, $notification_number ) { if( $formid == 12345 ) { $sender_email = $_REQUEST['sender-email-field-slug']; $sender_name = $_REQUEST['sender-name-field-slug']; $myheaders = array( "From: " . $sender_name . " <" . $sender_email . ">" ); return array_merge($headers, $myheaders); } return $headers; } add_filter('cred_mail_header', 'customise_cred_notifications', 10, 5);
Replace 12345 with the ID of your form, and replace sender-email-field-slug and sender-name-field-slug with the proper slugs from your generic fields.
Relevant Documentation:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_mail_header
https://toolset.com/documentation/user-guides/inserting-generic-fields-into-forms/
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 |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
This topic contains 6 replies, has 2 voices.
Last updated by 6 years, 7 months ago.
Assisted by: Christian Cox.