Make WordPress Core

Changeset 40980


Ignore:
Timestamp:
07/01/2017 01:29:09 PM (7 years ago)
Author:
boonebgorges
Message:

Users: Allow data to be filtered before updating or creating a user.

Props DaveFX.
Fixes #40545.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/user.php

    r40943 r40980  
    16431643    $data = wp_unslash( $compacted );
    16441644
     1645    if ( ! $update ) {
     1646        $data = $data + compact( 'user_login' );
     1647    }
     1648
     1649    /**
     1650     * Filters user data before the record is created or updated.
     1651     *
     1652     * It only includes data in the wp_users table wp_user, not any user metadata.
     1653     *
     1654     * @since 4.9.0
     1655     *
     1656     * @param array    $data {
     1657     *     Values and keys for the user.
     1658     *
     1659     *     @type string $user_login      The user's login. Only included if $update == false
     1660     *     @type string $user_pass       The user's password.
     1661     *     @type string $user_email      The user's email.
     1662     *     @type string $user_url        The user's url.
     1663     *     @type string $user_nicename   The user's nice name. Defaults to a URL-safe version of user's login
     1664     *     @type string $display_name    The user's display name.
     1665     *     @type string $user_registered MySQL timestamp describing the moment when the user registered. Defaults to
     1666     *                                   the current UTC timestamp.
     1667     * }
     1668     * @param bool     $update Whether the user is being updated rather than created.
     1669     * @param int|null $id     ID of the user to be updated, or NULL if the user is being created.
     1670     */
     1671    $data = apply_filters( 'wp_pre_insert_user_data', $data, $update, $update ? (int) $ID : null );
     1672
    16451673    if ( $update ) {
    16461674        if ( $user_email !== $old_user_data->user_email ) {
     
    16501678        $user_id = (int) $ID;
    16511679    } else {
    1652         $wpdb->insert( $wpdb->users, $data + compact( 'user_login' ) );
     1680        $wpdb->insert( $wpdb->users, $data );
    16531681        $user_id = (int) $wpdb->insert_id;
    16541682    }
Note: See TracChangeset for help on using the changeset viewer.