Overwrite new user email using html blade template

You use a hook for the custom mail HTML and render the template to a string and return it instead.

add_filter( 'wp_new_user_notification_email', 'custom_wp_new_user_notification_email', 10, 3 );

function custom_wp_new_user_notification_email( $wp_new_user_notification_email, $user, $blogname ) {
    $message =  \App\template('emails/welcome', compact('user', 'blogname'));
    $wp_new_user_notification_email['message'] = $message;
    return $wp_new_user_notification_email;
}

In this (admittedly untested) example the blade template receives the $user and $blogname variables and the rendered template is used as the email message.

Is this a Sage 9 or Sage 10 theme (Sage 10 template rendering)?

4 Likes