Make WordPress Core

Ticket #33587: 33587.6.diff

File 33587.6.diff, 8.0 KB (added by boonebgorges, 9 years ago)
  • src/wp-admin/includes/user.php

    diff --git src/wp-admin/includes/user.php src/wp-admin/includes/user.php
    index 5c12d3d..34fad91 100644
    function edit_user( $user_id = 0 ) { 
    175175        if ( $update ) {
    176176                $user_id = wp_update_user( $user );
    177177        } else {
    178                 $user_id = wp_insert_user( $user );
    179                 wp_new_user_notification( $user_id, 'both' );
     178                $user_id = wp_insert_user( $user, true );
    180179        }
    181180        return $user_id;
    182181}
    this email. This invitation will expire in a few days. 
    503502
    504503Please click the following link to activate your user account:
    505504%%s' ), get_bloginfo( 'name' ), home_url(), wp_specialchars_decode( translate_user_role( $role['name'] ) ) );
    506 }
    507  No newline at end of file
     505}
  • src/wp-admin/network/site-new.php

    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' ) ) { 
    9090        $user_id = email_exists($email);
    9191        if ( !$user_id ) { // Create a new user with a random password
    9292                $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 );
    9494                if ( false === $user_id )
    9595                        wp_die( __( 'There was an error creating the user.' ) );
    96                 else
    97                         wp_new_user_notification( $user_id, 'both' );
    9896        }
    9997
    10098        $wpdb->hide_errors();
  • src/wp-admin/network/site-users.php

    diff --git src/wp-admin/network/site-users.php src/wp-admin/network/site-users.php
    index eb692f5..63fa3cf 100644
    if ( $action ) { 
    7272                                $update = 'err_new';
    7373                        } else {
    7474                                $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 );
    7676
    7777                                if ( false === $user_id ) {
    7878                                        $update = 'err_new_dup';
    7979                                } else {
    80                                         wp_new_user_notification( $user_id, 'both' );
    8180                                        add_user_to_blog( $id, $user_id, $_POST['new_role'] );
    8281                                        $update = 'newuser';
    8382                                }
  • src/wp-admin/network/user-new.php

    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' ) ) { 
    4646                $add_user_errors = $user_details[ 'errors' ];
    4747        } else {
    4848                $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 );
    5050
    5151                if ( ! $user_id ) {
    5252                        $add_user_errors = new WP_Error( 'add_user_fail', __( 'Cannot add user.' ) );
    5353                } else {
    54                         wp_new_user_notification( $user_id, 'both' );
    5554                        wp_redirect( add_query_arg( array('update' => 'added'), 'user-new.php' ) );
    5655                        exit;
    5756                }
  • src/wp-includes/default-filters.php

    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' ); 
    338338add_action( 'comment_post', 'wp_new_comment_notify_moderator', 10, 2 );
    339339add_action( 'comment_post', 'wp_new_comment_notify_postauthor' );
    340340add_action( 'after_password_reset', 'wp_password_change_notification' );
     341add_action( 'user_register', 'wp_maybe_send_new_user_notifications', 10, 2 );
    341342
    342343/**
    343344 * Filters formerly mixed into wp-includes
  • src/wp-includes/ms-functions.php

    diff --git src/wp-includes/ms-functions.php src/wp-includes/ms-functions.php
    index 53d13c5..531c1b8 100644
    function wpmu_activate_signup($key) { 
    11061106 * @param string $user_name The new user's login name.
    11071107 * @param string $password  The new user's password.
    11081108 * @param string $email     The new user's email address.
     1109 * @param bool   $notify    Whether to notify the admin and user. Default: false.
    11091110 * @return int|false Returns false on failure, or int $user_id on success
    11101111 */
    1111 function wpmu_create_user( $user_name, $password, $email ) {
     1112function wpmu_create_user( $user_name, $password, $email, $notify = false ) {
    11121113        $user_name = preg_replace( '/\s+/', '', sanitize_user( $user_name, true ) );
    11131114
    1114         $user_id = wp_create_user( $user_name, $password, $email );
     1115        $user_id = wp_create_user( $user_name, $password, $email, $notify );
    11151116        if ( is_wp_error( $user_id ) )
    11161117                return false;
    11171118
  • src/wp-includes/user-functions.php

    diff --git src/wp-includes/user-functions.php src/wp-includes/user-functions.php
    index 1feac3b..601663e 100644
    function validate_username( $username ) { 
    12051205 *                                             site's frontend. Default true.
    12061206 *     @type string      $role                 User's role.
    12071207 * }
     1208 * @param bool $notify Whether to send email notifications to the admin and new user. Default: false.
    12081209 * @return int|WP_Error The newly created user's ID or a WP_Error object if the user could not
    12091210 *                      be created.
    12101211 */
    1211 function wp_insert_user( $userdata ) {
     1212function wp_insert_user( $userdata, $notify = false ) {
    12121213        global $wpdb;
    12131214
    12141215        if ( $userdata instanceof stdClass ) {
    function wp_insert_user( $userdata ) { 
    14781479                 * Fires immediately after a new user is registered.
    14791480                 *
    14801481                 * @since 1.5.0
     1482                 * @since 4.4.0 Added `$notify` parameter.
    14811483                 *
    14821484                 * @param int $user_id User ID.
    14831485                 */
    1484                 do_action( 'user_register', $user_id );
     1486                do_action( 'user_register', $user_id, $notify );
    14851487        }
    14861488
    14871489        return $user_id;
    All at ###SITENAME### 
    17201722 * @param string $username The user's username.
    17211723 * @param string $password The user's password.
    17221724 * @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.
    17231726 * @return int|WP_Error The newly created user's ID or a WP_Error object if the user could not
    17241727 *                      be created.
    17251728 */
    1726 function wp_create_user($username, $password, $email = '') {
     1729function wp_create_user( $username, $password, $email = '', $notify = false ) {
    17271730        $user_login = wp_slash( $username );
    17281731        $user_email = wp_slash( $email    );
    17291732        $user_pass = $password;
    17301733
    17311734        $userdata = compact('user_login', 'user_email', 'user_pass');
    1732         return wp_insert_user($userdata);
     1735        return wp_insert_user( $userdata, $notify );
    17331736}
    17341737
    17351738/**
    function register_new_user( $user_login, $user_email ) { 
    20042007                return $errors;
    20052008
    20062009        $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 );
    20082011        if ( ! $user_id || is_wp_error( $user_id ) ) {
    20092012                $errors->add( 'registerfail', sprintf( __( '<strong>ERROR</strong>: Couldn&#8217;t register you&hellip; please contact the <a href="mailto:%s">webmaster</a> !' ), get_option( 'admin_email' ) ) );
    20102013                return $errors;
    function register_new_user( $user_login, $user_email ) { 
    20122015
    20132016        update_user_option( $user_id, 'default_password_nag', true, true ); //Set up the Password change nag.
    20142017
    2015         wp_new_user_notification( $user_id, 'both' );
    2016 
    20172018        return $user_id;
    20182019}
    20192020
    20202021/**
     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 */
     2031function wp_maybe_send_new_user_notifications( $user_id, $notify ) {
     2032        if ( $notify ) {
     2033                wp_new_user_notification( $user_id, 'both' );
     2034        }
     2035}
     2036
     2037/**
    20212038 * Retrieve the current session token from the logged_in cookie.
    20222039 *
    20232040 * @since 4.0.0