Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
/**
* Plugin Name: Turn off new user registration emails
* Description: Turns off new user registration emails just for the admin. No other notifications are affected.
* Plugin URI: http://torstenlandsiedel.de
* Version: 1.0
* Author: Torsten Landsiedel
* Author URI: http://torstenlandsiedel.de
* Licence: GPL 2
* License URI: http://opensource.org/licenses/GPL-2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/*
* See: https://wordpress.stackexchange.com/questions/236122/turn-off-new-user-registration-emails
*/
add_action( 'init', function() {
remove_action( 'register_new_user', 'wp_send_new_user_notifications' );
add_action( 'register_new_user', 'wpse236122_send_new_user_notifications' );
} );
/**
* Initiates email notifications related to the creation of new users.
*
* Notifications are sent just to the newly created user.
*
* @since 4.4.0
* @since 4.6.0 Converted the `$notify` parameter to accept 'user' for sending
* notifications only to the user created.
*
* @param int $user_id ID of the newly created user.
* @param string $notify Optional. Type of notification that should happen. Accepts 'admin'
* or an empty string (admin only), 'user', or 'both' (admin and user).
* Default 'both'.
*/
function wpse236122_send_new_user_notifications( $user_id, $notify = 'user' ) {
wp_send_new_user_notifications( $user_id, $notify );
}
/**
* Disable call in BuddyPress.
*
* @link https://github.com/buddypress/BuddyPress/blob/fe47890c1ab7e2cb24c005f1c35fb9c6c8c8ab7c/src/bp-members/bp-members-functions.php#L1891-L1900
*/
add_filter( 'bp_core_send_user_registration_admin_notification', '__return_false' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.