Saltar navegación

[Resuelto] I want to change From in mail notification of post form with short code

This support ticket is created hace 1 mes. 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 – 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 13:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Sao_Paulo (GMT-03:00)

Este tema contiene 1 respuesta, tiene 1 mensaje.

Última actualización por Mateus Getulio hace 1 mes.

Asistido por: Mateus Getulio.

Autor
Mensajes
#2789086

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

#2789140

Mateus Getulio
Supporter

Idiomas: Inglés (English )

Zona horaria: America/Sao_Paulo (GMT-03:00)

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