Skip to content

Category: 

Change new user email content in WordPress

snippets

To change the content of the new user registration notification email in WordPress, which is sent to said user, we have a specific filter: wp_new_user_notification_email

With this filter, we have access to: recipient’s email address (by default that of the new user created), email subject, email body, email headers.

For example, here is the snippet to change the subject and body of the email:

add_filter( 'wp_new_user_notification_email', function( $wp_new_user_notification_email, $user, $blogname ) {

    $message = 'Thank you for registering :)';

    $wp_new_user_notification_email['subject'] = sprintf( 'Welcome to %s.', $blogname );
    $wp_new_user_notification_email['headers'] = array('Content-Type: text/html; charset=UTF-8');
    $wp_new_user_notification_email['message'] = $message;

    return $wp_new_user_notification_email;
    
}, $priority = 10, $accepted_args = 3 );
Open chat
Escríbenos
How is the plugin of your dreams? :)