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
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