Make WordPress Core

Ticket #40545: patch-add-hook.V4.diff

File patch-add-hook.V4.diff, 2.0 KB (added by DaveFX, 7 years ago)
  • wp-includes/user.php

    diff --git a/wp-includes/user.php b/wp-includes/user.php
    index 2bb4e0543..9f77672ab 100644
    a b function wp_insert_user( $userdata ) { 
    16371637        $compacted = compact( 'user_pass', 'user_email', 'user_url', 'user_nicename', 'display_name', 'user_registered' );
    16381638        $data = wp_unslash( $compacted );
    16391639
     1640        if ( ! $update ) {
     1641                $data = $data + compact( 'user_login' );
     1642        }
     1643
     1644        /**
     1645         * Filters user's data before the record is created or updated.
     1646         *
     1647         * It only includes data in Users table wp_user, not including any user metadata.
     1648         *
     1649         * @since 4.7.x
     1650         *
     1651         * @param array    $data {
     1652         *     Values and keys for the user.
     1653         *
     1654         *     @type string $user_login      The user's login. Only included if $update == false
     1655         *     @type string $user_pass       The user's password.
     1656         *     @type string $user_email      The user's email.
     1657         *     @type string $user_url        The user's url.
     1658         *     @type string $user_nicename   The user's nice name. Defaults to a URL-safe version of user's login
     1659         *     @type string $display_name    The user's display name.
     1660         *     @type string $user_registered MySQL timestamp describing the moment when the user registered. Defaults to
     1661         *                                   the current UTC timestamp.
     1662         * }
     1663         * @param bool     $update Whether the user is being updated rather than created.
     1664         * @param int|null $id     ID of the user to be updated, or NULL if the user is being created
     1665         */
     1666        $data = apply_filters( 'wp_pre_insert_user_data', $data, $update, $update ? (int) $ID : null );
     1667
    16401668        if ( $update ) {
    16411669                if ( $user_email !== $old_user_data->user_email ) {
    16421670                        $data['user_activation_key'] = '';
    function wp_insert_user( $userdata ) { 
    16441672                $wpdb->update( $wpdb->users, $data, compact( 'ID' ) );
    16451673                $user_id = (int) $ID;
    16461674        } else {
    1647                 $wpdb->insert( $wpdb->users, $data + compact( 'user_login' ) );
     1675                $wpdb->insert( $wpdb->users, $data );
    16481676                $user_id = (int) $wpdb->insert_id;
    16491677        }
    16501678