diff --git src/wp-admin/includes/user.php src/wp-admin/includes/user.php
index 5c12d3d..34fad91 100644
|
|
function edit_user( $user_id = 0 ) { |
175 | 175 | if ( $update ) { |
176 | 176 | $user_id = wp_update_user( $user ); |
177 | 177 | } else { |
178 | | $user_id = wp_insert_user( $user ); |
179 | | wp_new_user_notification( $user_id, 'both' ); |
| 178 | $user_id = wp_insert_user( $user, true ); |
180 | 179 | } |
181 | 180 | return $user_id; |
182 | 181 | } |
… |
… |
this email. This invitation will expire in a few days. |
503 | 502 | |
504 | 503 | Please click the following link to activate your user account: |
505 | 504 | %%s' ), get_bloginfo( 'name' ), home_url(), wp_specialchars_decode( translate_user_role( $role['name'] ) ) ); |
506 | | } |
507 | | No newline at end of file |
| 505 | } |
diff --git src/wp-admin/network/site-new.php src/wp-admin/network/site-new.php
index c5fa157..dc5733b 100644
|
|
if ( wp_validate_action( 'add-site' ) ) { |
90 | 90 | $user_id = email_exists($email); |
91 | 91 | if ( !$user_id ) { // Create a new user with a random password |
92 | 92 | $password = wp_generate_password( 12, false ); |
93 | | $user_id = wpmu_create_user( $domain, $password, $email ); |
| 93 | $user_id = wpmu_create_user( $domain, $password, $email, true ); |
94 | 94 | if ( false === $user_id ) |
95 | 95 | wp_die( __( 'There was an error creating the user.' ) ); |
96 | | else |
97 | | wp_new_user_notification( $user_id, 'both' ); |
98 | 96 | } |
99 | 97 | |
100 | 98 | $wpdb->hide_errors(); |
diff --git src/wp-admin/network/site-users.php src/wp-admin/network/site-users.php
index eb692f5..63fa3cf 100644
|
|
if ( $action ) { |
72 | 72 | $update = 'err_new'; |
73 | 73 | } else { |
74 | 74 | $password = wp_generate_password( 12, false); |
75 | | $user_id = wpmu_create_user( esc_html( strtolower( $user['username'] ) ), $password, esc_html( $user['email'] ) ); |
| 75 | $user_id = wpmu_create_user( esc_html( strtolower( $user['username'] ) ), $password, esc_html( $user['email'] ), true ); |
76 | 76 | |
77 | 77 | if ( false === $user_id ) { |
78 | 78 | $update = 'err_new_dup'; |
79 | 79 | } else { |
80 | | wp_new_user_notification( $user_id, 'both' ); |
81 | 80 | add_user_to_blog( $id, $user_id, $_POST['new_role'] ); |
82 | 81 | $update = 'newuser'; |
83 | 82 | } |
diff --git src/wp-admin/network/user-new.php src/wp-admin/network/user-new.php
index f2ccbb8..c55c517 100644
|
|
if ( wp_validate_action( 'add-user' ) ) { |
46 | 46 | $add_user_errors = $user_details[ 'errors' ]; |
47 | 47 | } else { |
48 | 48 | $password = wp_generate_password( 12, false); |
49 | | $user_id = wpmu_create_user( esc_html( strtolower( $user['username'] ) ), $password, sanitize_email( $user['email'] ) ); |
| 49 | $user_id = wpmu_create_user( esc_html( strtolower( $user['username'] ) ), $password, sanitize_email( $user['email'] ), true ); |
50 | 50 | |
51 | 51 | if ( ! $user_id ) { |
52 | 52 | $add_user_errors = new WP_Error( 'add_user_fail', __( 'Cannot add user.' ) ); |
53 | 53 | } else { |
54 | | wp_new_user_notification( $user_id, 'both' ); |
55 | 54 | wp_redirect( add_query_arg( array('update' => 'added'), 'user-new.php' ) ); |
56 | 55 | exit; |
57 | 56 | } |
diff --git src/wp-includes/default-filters.php src/wp-includes/default-filters.php
index 3d3c2f0..d411ed3 100644
|
|
add_action( 'wp_split_shared_term_batch', '_wp_batch_split_terms' ); |
338 | 338 | add_action( 'comment_post', 'wp_new_comment_notify_moderator', 10, 2 ); |
339 | 339 | add_action( 'comment_post', 'wp_new_comment_notify_postauthor' ); |
340 | 340 | add_action( 'after_password_reset', 'wp_password_change_notification' ); |
| 341 | add_action( 'user_register', 'wp_maybe_send_new_user_notifications', 10, 2 ); |
341 | 342 | |
342 | 343 | /** |
343 | 344 | * Filters formerly mixed into wp-includes |
diff --git src/wp-includes/ms-functions.php src/wp-includes/ms-functions.php
index 53d13c5..531c1b8 100644
|
|
function wpmu_activate_signup($key) { |
1106 | 1106 | * @param string $user_name The new user's login name. |
1107 | 1107 | * @param string $password The new user's password. |
1108 | 1108 | * @param string $email The new user's email address. |
| 1109 | * @param bool $notify Whether to notify the admin and user. Default: false. |
1109 | 1110 | * @return int|false Returns false on failure, or int $user_id on success |
1110 | 1111 | */ |
1111 | | function wpmu_create_user( $user_name, $password, $email ) { |
| 1112 | function wpmu_create_user( $user_name, $password, $email, $notify = false ) { |
1112 | 1113 | $user_name = preg_replace( '/\s+/', '', sanitize_user( $user_name, true ) ); |
1113 | 1114 | |
1114 | | $user_id = wp_create_user( $user_name, $password, $email ); |
| 1115 | $user_id = wp_create_user( $user_name, $password, $email, $notify ); |
1115 | 1116 | if ( is_wp_error( $user_id ) ) |
1116 | 1117 | return false; |
1117 | 1118 | |
diff --git src/wp-includes/user-functions.php src/wp-includes/user-functions.php
index 1feac3b..601663e 100644
|
|
function validate_username( $username ) { |
1205 | 1205 | * site's frontend. Default true. |
1206 | 1206 | * @type string $role User's role. |
1207 | 1207 | * } |
| 1208 | * @param bool $notify Whether to send email notifications to the admin and new user. Default: false. |
1208 | 1209 | * @return int|WP_Error The newly created user's ID or a WP_Error object if the user could not |
1209 | 1210 | * be created. |
1210 | 1211 | */ |
1211 | | function wp_insert_user( $userdata ) { |
| 1212 | function wp_insert_user( $userdata, $notify = false ) { |
1212 | 1213 | global $wpdb; |
1213 | 1214 | |
1214 | 1215 | if ( $userdata instanceof stdClass ) { |
… |
… |
function wp_insert_user( $userdata ) { |
1478 | 1479 | * Fires immediately after a new user is registered. |
1479 | 1480 | * |
1480 | 1481 | * @since 1.5.0 |
| 1482 | * @since 4.4.0 Added `$notify` parameter. |
1481 | 1483 | * |
1482 | 1484 | * @param int $user_id User ID. |
1483 | 1485 | */ |
1484 | | do_action( 'user_register', $user_id ); |
| 1486 | do_action( 'user_register', $user_id, $notify ); |
1485 | 1487 | } |
1486 | 1488 | |
1487 | 1489 | return $user_id; |
… |
… |
All at ###SITENAME### |
1720 | 1722 | * @param string $username The user's username. |
1721 | 1723 | * @param string $password The user's password. |
1722 | 1724 | * @param string $email Optional. The user's email. Default empty. |
| 1725 | * @param bool $notify Whether to notify the admin and new user via email. Default: false. |
1723 | 1726 | * @return int|WP_Error The newly created user's ID or a WP_Error object if the user could not |
1724 | 1727 | * be created. |
1725 | 1728 | */ |
1726 | | function wp_create_user($username, $password, $email = '') { |
| 1729 | function wp_create_user( $username, $password, $email = '', $notify = false ) { |
1727 | 1730 | $user_login = wp_slash( $username ); |
1728 | 1731 | $user_email = wp_slash( $email ); |
1729 | 1732 | $user_pass = $password; |
1730 | 1733 | |
1731 | 1734 | $userdata = compact('user_login', 'user_email', 'user_pass'); |
1732 | | return wp_insert_user($userdata); |
| 1735 | return wp_insert_user( $userdata, $notify ); |
1733 | 1736 | } |
1734 | 1737 | |
1735 | 1738 | /** |
… |
… |
function register_new_user( $user_login, $user_email ) { |
2004 | 2007 | return $errors; |
2005 | 2008 | |
2006 | 2009 | $user_pass = wp_generate_password( 12, false ); |
2007 | | $user_id = wp_create_user( $sanitized_user_login, $user_pass, $user_email ); |
| 2010 | $user_id = wp_create_user( $sanitized_user_login, $user_pass, $user_email, true ); |
2008 | 2011 | if ( ! $user_id || is_wp_error( $user_id ) ) { |
2009 | 2012 | $errors->add( 'registerfail', sprintf( __( '<strong>ERROR</strong>: Couldn’t register you… please contact the <a href="mailto:%s">webmaster</a> !' ), get_option( 'admin_email' ) ) ); |
2010 | 2013 | return $errors; |
… |
… |
function register_new_user( $user_login, $user_email ) { |
2012 | 2015 | |
2013 | 2016 | update_user_option( $user_id, 'default_password_nag', true, true ); //Set up the Password change nag. |
2014 | 2017 | |
2015 | | wp_new_user_notification( $user_id, 'both' ); |
2016 | | |
2017 | 2018 | return $user_id; |
2018 | 2019 | } |
2019 | 2020 | |
2020 | 2021 | /** |
| 2022 | * Initiate email notifications related to the creation of new users, if necessary. |
| 2023 | * |
| 2024 | * Notifications are sent both to the site admin and to the newly created user. |
| 2025 | * |
| 2026 | * @since 4.4.0 |
| 2027 | * |
| 2028 | * @param int $user_id ID of the newly created user. |
| 2029 | * @param bool $notify Whether to send the notification. Passed from the `$notify` param of `wp_insert_user()`. |
| 2030 | */ |
| 2031 | function wp_maybe_send_new_user_notifications( $user_id, $notify ) { |
| 2032 | if ( $notify ) { |
| 2033 | wp_new_user_notification( $user_id, 'both' ); |
| 2034 | } |
| 2035 | } |
| 2036 | |
| 2037 | /** |
2021 | 2038 | * Retrieve the current session token from the logged_in cookie. |
2022 | 2039 | * |
2023 | 2040 | * @since 4.0.0 |