I created a form, is contact form.
Then in the notification e-mail from, i would like to use email custom field used in the form.
The reason is receive an email like the contact were writing to me directly, to have the option to respond directly to the contact.
Is like a mask, the real email used is the setted in the wordpress, but when i click on reply send email to the contact.
How can i do that?
Please let me know if you don´t understand, my first language is spanish.
Hi, you can use custom code with the Forms API to manipulate email headers using custom field values. We have documentation available here: https://toolset.com/documentation/programmer-reference/cred-api/#cred_mail_header
Here is a quick example that changes the "From" header:
//Customise CRED notifications
function customise_cred_notifications( $headers, $formid, $postid, $notification_name, $notification_number ) {
if ($formid==12345 && $notification_name='Your notification name') {
$postemail = get_post_meta( $postid, 'wpcf-fieldslug', true );
$myheaders = array( 'From: ' . $postemail );
return array_merge($headers, $myheaders);
}
return $headers;
}
add_filter('cred_mail_header', 'customise_cred_notifications', 10, 5);
Change 12345 to match the Form ID. Change Your notification name to your notification name. Change fieldslug to match the email field slug. The 'wpcf-' prefix is required here.
Hello Christian,
Thanks for your reply.
I am little confused, where i have to add this code?.
When i update toolset or wordpress i have to add the code again?
Thanks.
You can add the code in a child theme's functions.php file, or you can create a new custom code snippet in Toolset > Settings > Custom Code. If you update Toolset or WordPress your snippets will not be deleted, they will remain in your theme or in the custom code section.
Hello Christian,
I understand, this process is a little tricky for me. I appreciate your good intention.
I thought by the UI i could do this process.
Thanks.
Let me know if you need additional assistance. I'll be glad to help you set this up.