Forked from someguy9/disable-wordpress-admin-new-user-notification.php
Created
October 27, 2022 15:26
-
-
Save temsool/ff64940aee54d1037a315a007b4f8ee1 to your computer and use it in GitHub Desktop.
Disable the WordPress new user email notification sent to the site admin
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 | |
//Disable the new user notification sent to the site admin | |
function smartwp_disable_new_user_notifications() { | |
//Remove original use created emails | |
remove_action( 'register_new_user', 'wp_send_new_user_notifications' ); | |
remove_action( 'edit_user_created_user', 'wp_send_new_user_notifications', 10, 2 ); | |
//Add new function to take over email creation | |
add_action( 'register_new_user', 'smartwp_send_new_user_notifications' ); | |
add_action( 'edit_user_created_user', 'smartwp_send_new_user_notifications', 10, 2 ); | |
} | |
function smartwp_send_new_user_notifications( $user_id, $notify = 'user' ) { | |
if ( empty($notify) || $notify == 'admin' ) { | |
return; | |
}elseif( $notify == 'both' ){ | |
//Only send the new user their email, not the admin | |
$notify = 'user'; | |
} | |
wp_send_new_user_notifications( $user_id, $notify ); | |
} | |
add_action( 'init', 'smartwp_disable_new_user_notifications' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment