What's wrong with Customizing new user notification email by add_filter?
When a new user signs up, the confirmation email is received and this is what it says:
Username: testuser To set your password, visit the following address:
But I want to customize it, so I added the following code to the functions.php
but it does not work. The default email is still sent.
I am using WordPress 4.9.9
?php
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 ) {
$wp_new_user_notification_email['subject'] = sprintf(__( '[%s] Your username and password' ), $blogname, $user-user_login );
$key = get_password_reset_key( $user );
$message = sprintf(__('Welcome to our website,')) . \r\n\r\n;
$message .= 'To set your password, visit the following address:' . \r\n\r\n;
$message .= network_site_url(wp-login.php?action=rpkey=$keylogin= . rawurlencode($user-user_login), 'login') . \r\n\r\n;
$message .= After this you can enjoy our website! . \r\n\r\n;
$message .= Kind regards, . \r\n;
$message .= Support Team . \r\n;
$wp_new_user_notification_email['message'] = $message;
$wp_new_user_notification_email['headers'] = 'From: [email protected]';
// this just changes the sender name and email to whatever you want (instead of the default WordPress [email protected]
return $wp_new_user_notification_email;
}
?
Why doesn't the code work? Would you help me?
Topic email-verification email user-registration customization Wordpress
Category Web