From cbe4f5d9c7bf7af79b30e7ed1ef75459ec79e5a3 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 21 Apr 2016 10:19:42 +0000 Subject: [PATCH] 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 --- src/wp-includes/pluggable.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/wp-includes/pluggable.php b/src/wp-includes/pluggable.php index 31533d5113..b08df9b954 100644 --- a/src/wp-includes/pluggable.php +++ b/src/wp-includes/pluggable.php @@ -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 ) ) ) {