Skip Navigation

[Resolved] Emails from a toolset form needs to "reply to" the person who submitted it

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

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

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 4 replies, has 2 voices.

Last updated by GravityStack 4 years, 3 months ago.

Assisted by: Waqar.

Author
Posts
#1456909

Tell us what you are trying to do?

I'm setting up a directory site, and I've got a form set up, and it appears on the listing page, example here: hidden link

If you fill out the form on that page with a message and an email address, it will send an email notification to the author of the listing you're looking at. Where I'm stuck is, if you reply to that email, it just goes to wordpress. It needs to go to the person who submitted the form (to the email address entered in the form).

Is there any documentation that you are following?

I used this to make the notification go to the post author: https://toolset.com/forums/topic/cred-unable-to-send-email-to-post-author/ but haven't found anything on the "reply to" bit.

Is there a similar example that we can see?

Hmm...I mean it's pretty standard functionality, like any directory site, if you post a listing, then someone contacts you about it, you'd probably just reply to the email that notified you of the response to your listing, and that reply would go to the person who made the original inquiry.

What is the link to your site?

hidden link

#1457297

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Scott,

Thank you for contacting us and I'd be happy to assist.

By default, "reply-to" would use the same email and name that is set in the form notification's "Notification e-mail from" fields.
( screenshot: hidden link )

If you'd like to link it to a field available in a form, you can use "cred_mail_header" hook:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_mail_header

For example, let's assume that your form has a generic field for an email with slug "form-email". The function for the reply-to header would look like this:


//Customise CRED notifications
function customise_cred_notifications( $headers, $formid, $postid, $notification_name, $notification_number ) {
    if ($formid==1234 && $notification_name=='notification name') {
        $myheaders = array( 'Reply-To: '.$_REQUEST["form-email"] );
        return array_merge($headers, $myheaders);
    }
    return $headers;
}
add_filter('cred_mail_header', 'customise_cred_notifications', 10, 5);

Note: Please replace "1234" and "notification name" with the actual ID if of the form and notification's name, respectively.

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#1464287
ts-email-field.png
ts-notification-name.png
ts-form-id.png

Ok cool, this looks like what I need.

I’ve added the code snippet you provided to my theme’s functions.php (assuming that’s correct) and updated the relevant bits. No magic yet though, so maybe I can just confirm if I’m doing it right…

I got my form’s ID from where you can see in the attached screenshot (1129).

And the notification name from the other attached image ("Send Inquiry").

And then this line:

$myheaders = array( 'Reply-To: '.$_REQUEST["email"] );

Where your example said $REQUEST[“form-email”] is updated to reference my email field that looks like the other attached image.

So my whole function looks like:

function customise_cred_notifications( $headers, $formid, $postid, $notification_name, $notification_number ) {
  if ($formid==1129 && $notification_name=='Send Inquiry') {
    $myheaders = array( 'Reply-To: '.$_REQUEST["email"] );
    return array_merge($headers, $myheaders);
  }
  return $headers;
}
add_filter('cred_mail_header', 'customise_cred_notifications', 10, 5);

Does that all seem like it should work? Did I miss something?

Thanks for your help!

#1468711

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thanks for writing back and for sharing the screenshots.

I noticed that your form is using a post custom field with slug "email", whereas the example snippet that I share, was for a case when a generic field is being used.

In case of a custom field, you'll replace the line:


 $myheaders = array( 'Reply-To: '.$_REQUEST["email"] );

With:


 $myheaders = array( 'Reply-To: '.$_REQUEST["wpcf-email"] );

Since "wpcf-" prefix is appended to the Toolset Types custom field slugs, in the backend.
( ref: https://toolset.com/documentation/customizing-sites-using-php/functions/ )

Please let me know how it goes.

#1469913

Awesome, that's exactly what I was missing, now it works, thanks!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.