Skip Navigation

[Resolved] Form – Notification e-mail from, can use custom field like email used in form?

This support ticket is created 5 years, 5 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.

Our next available supporter will start replying to tickets in about 0.35 hours from now. Thank you for your understanding.

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 5 replies, has 2 voices.

Last updated by Christian Cox 5 years, 5 months ago.

Assisted by: Christian Cox.

Author
Posts
#1277709

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.

#1277791

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.

#1277967

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.

#1278585

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.

#1279135

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.

#1280339

Let me know if you need additional assistance. I'll be glad to help you set this up.