mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-22 17:18:32 +01:00
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. Built from https://develop.svn.wordpress.org/trunk@34251 git-svn-id: http://core.svn.wordpress.org/trunk@34215 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
f6fb4653eb
commit
85c00bd943
@ -176,7 +176,14 @@ function edit_user( $user_id = 0 ) {
|
||||
$user_id = wp_update_user( $user );
|
||||
} else {
|
||||
$user_id = wp_insert_user( $user );
|
||||
wp_new_user_notification( $user_id, null, 'both' );
|
||||
/**
|
||||
* Fires after a new user has been created.
|
||||
*
|
||||
* @since 4.4.0
|
||||
*
|
||||
* @param int $user_id ID of the newly created user.
|
||||
*/
|
||||
do_action( 'edit_user_created_user', $user_id );
|
||||
}
|
||||
return $user_id;
|
||||
}
|
||||
|
@ -91,10 +91,18 @@ if ( wp_validate_action( 'add-site' ) ) {
|
||||
if ( !$user_id ) { // Create a new user with a random password
|
||||
$password = wp_generate_password( 12, false );
|
||||
$user_id = wpmu_create_user( $domain, $password, $email );
|
||||
if ( false === $user_id )
|
||||
if ( false === $user_id ) {
|
||||
wp_die( __( 'There was an error creating the user.' ) );
|
||||
else
|
||||
wp_new_user_notification( $user_id, null, 'both' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Fires after a new user has been created via the network site-new.php page.
|
||||
*
|
||||
* @since 4.4.0
|
||||
*
|
||||
* @param int $user_id ID of the newly created user.
|
||||
*/
|
||||
do_action( 'network_site_new_created_user', $user_id );
|
||||
}
|
||||
|
||||
$wpdb->hide_errors();
|
||||
|
@ -77,9 +77,16 @@ if ( $action ) {
|
||||
if ( false === $user_id ) {
|
||||
$update = 'err_new_dup';
|
||||
} else {
|
||||
wp_new_user_notification( $user_id, null, 'both' );
|
||||
add_user_to_blog( $id, $user_id, $_POST['new_role'] );
|
||||
$update = 'newuser';
|
||||
/**
|
||||
* Fires after a user has been created via the network site-users.php page.
|
||||
*
|
||||
* @since 4.4.0
|
||||
*
|
||||
* @param int $user_id ID of the newly created user.
|
||||
*/
|
||||
do_action( 'network_site_users_created_user', $user_id );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -51,7 +51,14 @@ if ( wp_validate_action( 'add-user' ) ) {
|
||||
if ( ! $user_id ) {
|
||||
$add_user_errors = new WP_Error( 'add_user_fail', __( 'Cannot add user.' ) );
|
||||
} else {
|
||||
wp_new_user_notification( $user_id, null, 'both' );
|
||||
/**
|
||||
* Fires after a new user has been created via the network user-new.php page.
|
||||
*
|
||||
* @since 4.4.0
|
||||
*
|
||||
* @param int $user_id ID of the newly created user.
|
||||
*/
|
||||
do_action( 'network_user_new_created_user', $user_id );
|
||||
wp_redirect( add_query_arg( array('update' => 'added'), 'user-new.php' ) );
|
||||
exit;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
*
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.4-alpha-34250';
|
||||
$wp_version = '4.4-alpha-34251';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user