Skip Navigation

[Resolved] Form reply to address

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

Problem:

The problem here is that the user wanted to do a custom from Header in their email. This email should come from the form dynamically.

Solution:
You aren't able to do this using the user interface on the backend, however it is possible to modify the email header using the hook below.
https://toolset.com/documentation/programmer-reference/cred-api/#cred_mail_header

Based on the custom field i'm assuming that you're getting the email from the current post that is being created by the form. In this case you should be able to do this.

function customise_cred_notifications( $headers, $formid, $postid, $notification_name, $notification_number ) {
   if ($formid==5 && $notification_name=='some name'){
    $myheaders = array();
    $email = get_post_meta('wpcf-consumeremail', $postid);
    $myheaders = array( 'Reply-To: '.$email);
    return array_merge($headers, $myheaders);
}
      return $headers;
}
add_filter('cred_mail_header', 'customise_cred_notifications', 10, 5);

In this code you will replace the 5 with the ID of your form and 'some name' with the name of the notification that you want to target.

This support ticket is created 3 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.43 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 2 replies, has 2 voices.

Last updated by pierre-yvesC 3 years, 5 months ago.

Assisted by: Shane.

Author
Posts
#2096973

Hi,

In a form, I want the ”from” email address to be dynamic. From the people who filled the form. So it may be :

Email (leave blank for default): [types field='consumeremail' output='raw']

But ToolsetForm allow only ”real” email addresses, such as noreply@mydomainname.com

Is there a way to fix that?

Many thx.

#2097147

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Pierre,

Thank you for getting in touch.

You aren't able to do this using the user interface on the backend, however it is possible to modify the email header using the hook below.
https://toolset.com/documentation/programmer-reference/cred-api/#cred_mail_header

Based on the custom field i'm assuming that you're getting the email from the current post that is being created by the form. In this case you should be able to do this.

function customise_cred_notifications( $headers, $formid, $postid, $notification_name, $notification_number ) {
   if ($formid==5 && $notification_name=='some name'){
    $myheaders = array();
    $email = get_post_meta('wpcf-consumeremail', $postid);
    $myheaders = array( 'Reply-To: '.$email);
    return array_merge($headers, $myheaders);
}
      return $headers
}
add_filter('cred_mail_header', 'customise_cred_notifications', 10, 5);

In this code you will replace the 5 with the ID of your form and 'some name' with the name of the notification that you want to target.

Please let me know if this helps.
Thanks,
Shane

#2101389

Works perfectly, many thx!