WordPress.org

Make WordPress Core

Changeset 18909


Ignore:
Timestamp:
10/07/2011 02:34:41 AM (10 years ago)
Author:
ryan
Message:

Don't stomp meta fields in wp_update_user(). Props scribu. see #15458

Location:
trunk/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/capabilities.php

    r18633 r18909  
    475475     * @param string $field The field to query against: 'id', 'slug', 'email' or 'login'
    476476     * @param string|int $value The field value
     477     * @return object Raw user object
    477478     */
    478479    static function get_data_by( $field, $value ) {
     
    619620     * used.
    620621     *
     622     * @access protected
    621623     * @since 2.1.0
    622624     *
    623625     * @param string $cap_key Optional capability key
    624      * @access protected
    625626     */
    626627    function _init_caps( $cap_key = '' ) {
  • trunk/wp-includes/user.php

    r18906 r18909  
    13551355    }
    13561356
    1357     update_user_meta( $user_id, 'first_name', $first_name );
    1358     update_user_meta( $user_id, 'last_name', $last_name );
    1359     update_user_meta( $user_id, 'nickname', $nickname );
    1360     update_user_meta( $user_id, 'description', $description );
    1361     update_user_meta( $user_id, 'rich_editing', $rich_editing );
    1362     update_user_meta( $user_id, 'comment_shortcuts', $comment_shortcuts );
    1363     update_user_meta( $user_id, 'admin_color', $admin_color );
    1364     update_user_meta( $user_id, 'use_ssl', $use_ssl );
    1365     update_user_meta( $user_id, 'show_admin_bar_front', $show_admin_bar_front );
    1366 
    1367     $user = new WP_User($user_id);
    1368 
    1369     foreach ( _wp_get_user_contactmethods( $user ) as $method => $name ) {
    1370         if ( empty($$method) )
    1371             $$method = '';
    1372 
    1373         update_user_meta( $user_id, $method, $$method );
     1357    $user = new WP_User( $user_id );
     1358
     1359    foreach ( _get_additional_user_keys( $user ) as $key ) {
     1360        update_user_meta( $user_id, $key, $$key );
    13741361    }
    13751362
     
    14131400
    14141401    // First, get all of the original fields
    1415     $user = WP_User::get_data_by('id', $ID);
     1402    $user_obj = get_userdata( $ID );
     1403
     1404    $user = get_object_vars( $user_obj->data );
     1405
     1406    // Add additional custom fields
     1407    foreach ( _get_additional_user_keys( $user_obj ) as $key ) {
     1408        $user[ $key ] = get_user_meta( $ID, $key, true );
     1409    }
    14161410
    14171411    // Escape data pulled from DB.
    1418     $user = add_magic_quotes(get_object_vars($user));
     1412    $user = add_magic_quotes( $user );
    14191413
    14201414    // If password is changing, hash it now.
     
    14651459}
    14661460
     1461
     1462/**
     1463 * Return a list of meta keys that wp_insert_user() is supposed to set.
     1464 *
     1465 * @access private
     1466 * @since 3.3.0
     1467 *
     1468 * @param object $user WP_User instance
     1469 * @return array
     1470 */
     1471function _get_additional_user_keys( $user ) {
     1472    $keys = array( 'first_name', 'last_name', 'nickname', 'description', 'rich_editing', 'comment_shortcuts', 'admin_color', 'use_ssl', 'show_admin_bar_front' );
     1473    return array_merge( $keys, array_keys( _wp_get_user_contactmethods( $user ) ) );
     1474}
    14671475
    14681476/**
Note: See TracChangeset for help on using the changeset viewer.