mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-10-03 22:27:04 +00: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. git-svn-id: https://develop.svn.wordpress.org/trunk@34251 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user