Stop sending email to new user in WordPress admin registration

Prevent WordPress to send notification emails when you manually create new users

March 9, 2017

WordPress (recent version > 4.7) now sends an email to the user when you create a new user in your back office.
Have you noticed the “Send the new user an email about their account” checkbox?

It is checked by default, and when it’s checked:

 

WordPress will send an email to the new user telling him to reset its password. For securit reasonds, WordPress will also not send anymore the user  password, even if you manually set the new password.

How to prevent WordPress to send the new user email about their account (without manually uncheck)

If you’re mannually creating users and you forget to uncheck this checkbox the user will receive the email.

This small snippet modifies the default value for this checkbox, so when you add a new user the checkbox is already unchecked.

This code hooks into the user_new_form action to add a small javascript that uncheck the default checked checkbox to send to the user a notification email about his account on your WordPress site.

add_action( 'user_new_form', 'dontchecknotify_register_form' );
function dontchecknotify_register_form() {
	echo '<scr'.'ipt>
	jQuery(document).ready(function($) {
		$("#send_user_notification").removeAttr("checked");
	} );
	</scr'.'ipt>';
}

If you want to completely block WordPress from sending emails create this small plugin in your /wp-content/plugins directory (call it no-email.php), go in the plugins page and activate it:

/*
Plugin Name: Block email notification
Plugin URI: http://www.barattalo.it/
Description: Blocca invie notifiche email
Author: Better Days
Version: 1
*/

// disable all new user notification email
if ( ! function_exists( 'wp_new_user_notification' ) ) :
    function wp_new_user_notification( $user_id, $deprecated = null, $notify = '' ) {
        return;
    }
endif;

This code snippet can’t be included in your functions.php because it doesn’t work on a hook but works on core pluggable functions overwriting the existing wp_new_user_notification function.

Pluggable functions are functions declared by WordPress before your function.php file, but after plugins scripts, so you can override them from a plugin, declaring them before WordPress. You have to check if the function already exists because another plugin could have already declared and if you don’t check you got an error. Override a pluggable function always inside a if(function_exists(...)) check to avoid errors.

To understand better the WordPress pluggable functios you can read this page.

Author

I'm a software engineer, an everyday web developer and a maker. I usually build sites with PHP, within or without WordPress. I build Internet of Things with Arduino and ESP8266. I'm the founder of Rockit.it and Dailybest.it and I'm actually the Chief Technical Officer of Better Days web agency.

Recommended

Add filter on wp_title not working with Yoast SEO plugin

For SEO purposes, in a specific template that has a list of items with pagination, I need to have different…

February 22, 2017

Generate all old PDF preview images with WordPress 4.7

WordPress 4.7 generates thumbnails for PDF files while uploading them in the media library, this is a really good thing…

December 13, 2016

Clean up and optimize WordPress head tag

If you need to know how to remove RSS Feed URL’s from page head or how to remove post relational…

December 11, 2015

A new avatar generator for WordPress with get_avatar and Flathash

Brand new avatars for WordPress Gravatar service

April 7, 2017

3 ways to add author’s image in WordPress

Add author's image in WordPress without a plugin

April 5, 2017

Add Internet Explorer class to body to detect old browser

When you have clients that still uses an old browser, you need to handle it. This javascript function detects the…

February 27, 2017