• Hi All,

    I’m trying to overwrite wp_new_user_notification as I don’t want to receive an email every time someone new registers.

    I have copied the code from wp-includes/pluggable.php and put it into my functions.php file as:

    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);
    
        // The blogname option is escaped with esc_html on the way into the database in sanitize_option
        // we want to reverse this for the plain text arena of emails.
        $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;

    You will notice I have removed the first part of the function that should email the admin.

    However it’s ignoring this function and still using the default one.

    Any ideas why?

    Thanks,
    Sam

Viewing 1 replies (of 1 total)
  • Thread Starter Sam Scholfield

    (@sam-s)

    Nevermind I figured it out. You can’t put the code into functions.php. It has to go into a plugin.

    Thanks anyway 🙂

Viewing 1 replies (of 1 total)
  • The topic ‘wp_new_user_notification pluggable function’ is closed to new replies.