Hi Support Team,
I have one issue in Toolset post form one of my post form have mail notification when submit form in that notification i want to change From name with Shortcode set in From name but it is not working.
I receive notification with shortcode instead of shortcode value.
Can you please help me with this issue?
Thanks
Hello there,
I'm afraid that there isn't such a built-in feature within Toolset Forms plugin, it needs custom code, you can use filter hook "cred_mail_header" to trigger a custom PHP function, and change the mail from name to what you want. For example:
there is a Toolset form(ID: 123) sending the email notification, and you are going to change the email from name to custom field "customer-name", this custom field is created with Types plugin.
You can try this custom code:
function customise_cred_notifications( $headers, $formid, $postid, $notification_name, $notification_number ) {
if ($formid==123 && $notification_number==0) {
add_filter('wp_mail_from_name', 'mail_from_name_func', 11, 1);
}
return $headers;
}
add_filter('cred_mail_header', 'customise_cred_notifications', 999, 5);
function mail_from_name_func($name){
$name = get_post_meta(get_the_ID(), 'wpcf-customer-name', true);
$name = sanitize_text_field($name);
return $name;
}
Please give it a try and let us know how that goes.
Mateus