Move new user notification emails to add_action() callbacks.

When a new user is created in various places throughout the interface,
notifications are sent to the site admin and the new user. Previously, these
notifications were fired through direct calls to `wp_new_user_notification()`,
making it difficult to stop or modify the messages.

This changeset introduces a number of new action hooks in place of direct calls
to `wp_new_user_notification()`, and hooks the new wrapper function
`wp_send_new_user_notifications()` to these hooks.

Props dshanske, thomaswm, boonebgorges.
Fixes #33587.

git-svn-id: https://develop.svn.wordpress.org/trunk@34251 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Boone Gorges
2015-09-16 22:18:33 +00:00
parent d26b868870
commit de7c9b6015
7 changed files with 61 additions and 7 deletions
+2
View File
@@ -339,6 +339,8 @@ add_action( 'wp_split_shared_term_batch', '_wp_batch_split_terms' );
add_action( 'comment_post', 'wp_new_comment_notify_moderator', 10, 2 );
add_action( 'comment_post', 'wp_new_comment_notify_postauthor' );
add_action( 'after_password_reset', 'wp_password_change_notification' );
add_action( 'register_new_user', 'wp_send_new_user_notifications' );
add_action( 'edit_user_created_user', 'wp_send_new_user_notifications' );
/**
* Filters formerly mixed into wp-includes
+3
View File
@@ -27,6 +27,9 @@ add_action( 'wpmu_new_user', 'newuser_notify_siteadmin' );
add_action( 'wpmu_activate_user', 'add_new_user_to_blog', 10, 3 );
add_action( 'wpmu_activate_user', 'wpmu_welcome_user_notification', 10, 3 );
add_action( 'after_signup_user', 'wpmu_signup_user_notification', 10, 4 );
add_action( 'network_site_new_created_user', 'wp_send_new_user_notifications' );
add_action( 'network_site_users_created_user', 'wp_send_new_user_notifications' );
add_action( 'network_user_new_created_user', 'wp_send_new_user_notifications' );
add_filter( 'sanitize_user', 'strtolower' );
// Blogs
+21 -1
View File
@@ -2023,11 +2023,31 @@ function register_new_user( $user_login, $user_email ) {
update_user_option( $user_id, 'default_password_nag', true, true ); //Set up the Password change nag.
wp_new_user_notification( $user_id, null, 'both' );
/**
* Fires after a new user registration has been recorded.
*
* @since 4.4.0
*
* @param int $user_id ID of the newly registered user.
*/
do_action( 'register_new_user', $user_id );
return $user_id;
}
/**
* Initiate email notifications related to the creation of new users.
*
* Notifications are sent both to the site admin and to the newly created user.
*
* @since 4.4.0
*
* @param int $user_id ID of the newly created user.
*/
function wp_send_new_user_notifications( $user_id ) {
wp_new_user_notification( $user_id, null, 'both' );
}
/**
* Retrieve the current session token from the logged_in cookie.
*