Per the filter’s documentation, the $content
should be formatted for use by wp_mail()
. In the wp_mail()
documentation, I find this:
The default charset is based on the charset used on the blog. The charset can be set using the
wp_mail_charset
filter.
So it appears you need to explicitly allow WordPress to send HTML mail. See the User Contributed Notes section of the wp_mail_charset
filter documentation.
Here’s how I’d tackle your question:
/**
* Filter the mail content type.
*/
function wpse360648_set_html_mail_content_type() {
return 'text/html';
}
add_filter( 'wp_mail_content_type', 'wpse360648_set_html_mail_content_type' );
function wpse360648_user_notification_email( $content, $user_login, $user_email, $key, $meta ) {
$m = "<h1>Thanks for signing up</h1>";
$m .= $content;
return $m;
}
add_filter('wpmu_signup_user_notification_email', 'wpse360648_user_notification_email', 10, 5);
// Reset content-type to avoid conflicts -- https://core.trac.wordpress.org/ticket/23578
remove_filter( 'wp_mail_content_type', 'wpse360648_set_html_mail_content_type' );
(based on code by Helen Hou-Sandi)