So, WordPress 4.3 has a new password system as we all know.
Unfortunately, this new system has done away with the ability to NOT send new users an email.

My client was using a system where he sent a custom email to his clients, manually registering their emails, and then sending them an email with the login info with a custom message. We are aware that this new system is trying to be more secure, but this isn’t working for the amount of control he would like.

I’ve found the following code in my search for a solution to turn these emails off, but I think they only turn off the notification emails for if a user’s email is CHANGED for previously registered users, not when it’s first created:

add_filter( 'send_password_change_email', '__return_false');
add_filter( 'send_email_change_email', '__return_false');

Does anyone know of any way to turn off these initial password emails sent after registration?

Thank you.

5

You can intercept this email before it is sent using the phpmailer_init hook.

By default, this hook fires before any email is sent. In the function below, $phpmailer will be an instance of PHPMailer, and you can use its methods to remove the default recipient and manipulate the email before it is sent.

add_action('phpmailer_init', 'wse199274_intercept_registration_email');
function wse199274_intercept_registration_email($phpmailer){
    $admin_email = get_option( 'admin_email' );

    # Intercept username and password email by checking subject line
    if( strpos($phpmailer->Subject, 'Your username and password info') ){
        # clear the recipient list
        $phpmailer->ClearAllRecipients();
        # optionally, send the email to the WordPress admin email
        $phpmailer->AddAddress($admin_email);
    }else{
        #not intercepted
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *