Make WordPress Core

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

File patch-add-hook.v3.diff, 1.9 KB (added by DaveFX, 8 years ago)

New version of the patch, now renaming the filter name, according to what @rachelbaker suggested

  • wp-includes/user.php

    diff --git a/wp-includes/user.php b/wp-includes/user.php
    index dcd102623..cfc2d5e3b 100644
    a b function wp_insert_user( $userdata ) { 
    16271627        $compacted = compact( 'user_pass', 'user_email', 'user_url', 'user_nicename', 'display_name', 'user_registered' );
    16281628        $data = wp_unslash( $compacted );
    16291629
     1630        if ( ! $update ) {
     1631                $data = $data + compact( 'user_login' );
     1632        }
     1633
     1634        /**
     1635         * Filters user's data before the record is created or updated.
     1636         *
     1637         * It only includes data in Users table wp_user, not including any user metadata.
     1638         *
     1639         * @since 4.7.x
     1640         *
     1641         * @param array $data {
     1642         *     Values and keys for the user.
     1643         *
     1644         *     @type string $user_login      The user's login. Only included if $update == false
     1645         *     @type string $user_pass       The user's password.
     1646         *     @type string $user_email      The user's email.
     1647         *     @type string $user_url        The user's url.
     1648         *     @type string $user_nicename   The user's nice name. Defaults to a URL-safe version of user's login
     1649         *     @type string $display_name    The user's display name.
     1650         *     @type string $user_registered MySQL timestamp describing the moment when the user registered. Defaults to
     1651         *                                   the current UTC timestamp.
     1652         * }
     1653         * @param bool    $update Whether the user is being updated rather than created.
     1654         */
     1655        $data = apply_filters( 'wp_pre_insert_user_data', $data, $update );
     1656
    16301657        if ( $update ) {
    16311658                if ( $user_email !== $old_user_data->user_email ) {
    16321659                        $data['user_activation_key'] = '';
    function wp_insert_user( $userdata ) { 
    16341661                $wpdb->update( $wpdb->users, $data, compact( 'ID' ) );
    16351662                $user_id = (int) $ID;
    16361663        } else {
    1637                 $wpdb->insert( $wpdb->users, $data + compact( 'user_login' ) );
     1664                $wpdb->insert( $wpdb->users, $data );
    16381665                $user_id = (int) $wpdb->insert_id;
    16391666        }
    16401667