Users: In `wp_new_user_notification()`, sdd `'user'` option for the `$notify` parameter, which allows for sending notification only to the user created.

Props akibjorklund.
Fixes #36009.

git-svn-id: https://develop.svn.wordpress.org/trunk@37276 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2016-04-21 10:19:42 +00:00
parent c52f851308
commit cbe4f5d9c7
1 changed files with 8 additions and 5 deletions

View File

@ -1691,6 +1691,7 @@ if ( !function_exists('wp_new_user_notification') ) :
* @since 2.0.0
* @since 4.3.0 The `$plaintext_pass` parameter was changed to `$notify`.
* @since 4.3.1 The `$plaintext_pass` parameter was deprecated. `$notify` added as a third parameter.
* @since 4.6.0 The `$notify` parameter accepts 'user' for sending notification only to the user created.
*
* @global wpdb $wpdb WordPress database object for queries.
* @global PasswordHash $wp_hasher Portable PHP password hashing framework instance.
@ -1698,7 +1699,7 @@ if ( !function_exists('wp_new_user_notification') ) :
* @param int $user_id User ID.
* @param null $deprecated Not used (argument deprecated).
* @param string $notify Optional. Type of notification that should happen. Accepts 'admin' or an empty
* string (admin only), or 'both' (admin and user). Default empty.
* string (admin only), 'user', or 'both' (admin and user). Default empty.
*/
function wp_new_user_notification( $user_id, $deprecated = null, $notify = '' ) {
if ( $deprecated !== null ) {
@ -1712,11 +1713,13 @@ function wp_new_user_notification( $user_id, $deprecated = null, $notify = '' )
// we want to reverse this for the plain text arena of emails.
$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
$message = sprintf(__('New user registration on your site %s:'), $blogname) . "\r\n\r\n";
$message .= sprintf(__('Username: %s'), $user->user_login) . "\r\n\r\n";
$message .= sprintf(__('Email: %s'), $user->user_email) . "\r\n";
if ( 'user' !== $notify ) {
$message = sprintf( __( 'New user registration on your site %s:' ), $blogname ) . "\r\n\r\n";
$message .= sprintf( __( 'Username: %s' ), $user->user_login ) . "\r\n\r\n";
$message .= sprintf( __( 'Email: %s' ), $user->user_email ) . "\r\n";
@wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), $blogname), $message);
@wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] New User Registration' ), $blogname ), $message );
}
// `$deprecated was pre-4.3 `$plaintext_pass`. An empty `$plaintext_pass` didn't sent a user notifcation.
if ( 'admin' === $notify || ( empty( $deprecated ) && empty( $notify ) ) ) {