Turn off admin emails for new user registrations

Function wp_new_user_notification is pluggable. It means that you can override it by declaring your version of this function in your plugin/theme.

So, if you wish to disable all notifications completely, do it like this:

if ( !function_exists( 'wp_new_user_notification' ) ) :
function wp_new_user_notification( $user_id, $plaintext_pass="" ) {
    return;
}
endif;

However I wouldn’t recommend you to disable all notifications, and would recommend you to send notification to an user at least (How does an user find out his password?). So in this case your code should be following:

if ( !function_exists( 'wp_new_user_notification' ) ) :
function wp_new_user_notification( $user_id, $plaintext_pass="" ) {
    $user = get_userdata( $user_id );

    $user_login = stripslashes($user->user_login);
    $user_email = stripslashes($user->user_email);

    $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);

    if ( empty($plaintext_pass) ) {
        return;
    }

    $message  = sprintf(__('Username: %s'), $user_login) . "\r\n";
    $message .= sprintf(__('Password: %s'), $plaintext_pass) . "\r\n";
    $message .= wp_login_url() . "\r\n";

    wp_mail($user_email, sprintf(__('[%s] Your username and password'), $blogname), $message);
}
endif;

Leave a Comment