Last active
September 7, 2018 08:48
-
-
Save Zodiac1978/36126ae3d4ac6ba1c38cfc0d42773445 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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