Skip Navigation

[Resolved] How to set post form FROM field to author email instead of default email

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 1 reply, has 2 voices.

Last updated by Waqar 1 year ago.

Assisted by: Waqar.

Author
Posts
#2584277
Screenshot 2023-03-31 at 11.42.13 AM.png

Tell us what you are trying to do?

My site allows sales reps to generate and send quotes to customers. The link to the each quote is emailed to a recipient using a Toolset Form Notification. I would like the FROM address on that notification to be the sales rep's email, rather than the generic WordPress admin email.

The field for entering the FROM address in a Toolset Form only allows text and provides no additional controls or buttons for adding the quote author's email as the FROM address.

Is there a way to do this with JavaScript?

Is there any documentation that you are following? Standard Post Forms documentation

Is there a similar example that we can see? N/A

What is the link to your site? hidden link

#2585783

Waqar
Supporter

Languages: English (English )

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

Hi,

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

The Toolset Form notifications don't support setting up a dynamic 'From' email and name. Also, in terms of reliable email delivery, it is considered a good practice to use a same-domain email address for the outgoing emails, anyways.

An alternative can be to set the current user's email as the 'Reply-To' email in the notification. This way, when the notification recipient will use the reply option for that email, the sales rep's email will be used and not the one that is set as the 'From' email.

To include the 'Reply-To' header in the email, you can use the 'cred_mail_header' filter, like this:
( ref: https://toolset.com/documentation/programmer-reference/cred-api/#cred_mail_header )


function customise_cred_notifications( $headers, $formid, $postid, $notification_name, $notification_number ) {
	// check for the specific form and form notification
	if ($formid==12345 && $notification_name=='Test notification') {
		// get the current user's email
		$current_user_email = do_shortcode('[wpv-user field="user_email"]');
		// add custom header information
		$myheaders = array( 'Reply-To: '.$current_user_email);
		return array_merge($headers, $myheaders);
	}

	return $headers;
}
add_filter('cred_mail_header', 'customise_cred_notifications', 10, 5);

Note: You'll replace '12345' with the target form's ID and the 'Test notification' with the name of the target notification.

The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through the active theme's "functions.php" file.

regards,
Waqar

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