Reputation: 87
Good Day,
I am trying to edit the headers sent by WordPress for the user activation mail in HTML format.
Problem 1
I used the following filter, but the email is sent twice. Once from this function and the other from the original function.
Problem 2
I then add a filter to the wpmu_signup_user_notification_email to change the message to HTML but when I send the message the activation message the email is blank (in both emails) but headers are correct.
Problem 1 Filter
add_filter( 'wpmu_signup_user_notification', 'tpb_signup_user_notification', 10, 4 );
function tpb_signup_user_notification( $user, $user_email, $key, $meta = array() )
{
// Send email with activation link.
$admin_email = '[email protected]';
if ( $admin_email == '' )
$admin_email = 'support@' . $_SERVER['SERVER_NAME'];
$from_name = get_site_option( 'site_name' ) == '' ? 'Name Here' : esc_html( get_site_option( 'site_name' ) );
$message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/html; charset=\"" . get_option('blog_charset') . "\"\n";
...
wp_mail($user_email, $subject, $message, $message_headers);
return true;
}
Problem 2 Filter
function wpse56797_signup_blog_notification_email( $message, $user, $user_email, $key )
{
$message = '<table>....</table>';
}
apply_filter('wpmu_signup_user_notification_email','wpse56797_signup_blog_notification_email', 10, 4 );
Upvotes: 0
Views: 920
Reputation: 1495
I just had Problem 1 on my site and the solution is that you need to return false instead of true from your tpb_signup_user_notification function because in the core function wpmu_signup_user_notification you have
if ( ! apply_filters( 'wpmu_signup_user_notification', $user, $user_email, $key, $meta ) )
return false;
so when you return false from your function the above condition evaluates to true thus exiting out of the core function
Upvotes: 2
Reputation: 11
Your function shown under "Problem 2" should probably return the HTML content.
e.g.
return $message;
Upvotes: 1