Skip Navigation

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

This support ticket is created hace 5 años, 5 meses. 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

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)

Este tema contiene 5 respuestas, tiene 2 mensajes.

Última actualización por Christian Cox hace 5 años, 5 meses.

Asistido por: Christian Cox.

Autor
Mensajes
#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.