WordPress.org

Make WordPress Core

Ticket #5787: comment_user_info.diff

File comment_user_info.diff, 1.4 KB (added by fitztrev, 10 years ago)
  • registration.php

     
    207207 * If $userdata does not contain an 'ID' key, then a new user
    208208 * will be created and the new user's ID will be returned.
    209209 *
     210 * Updates the user's past comments with the new display name,
     211 * email address, and URL, if changed.
     212 *
    210213 * If current user's password is being updated, then the cookies
    211214 * will be cleared.
    212215 *
     
    218221 * @return int The updated user's ID.
    219222 */
    220223function wp_update_user($userdata) {
     224        global $wpdb;
     225
    221226        $ID = (int) $userdata['ID'];
    222227
    223228        // First, get all of the original fields
     
    232237                $userdata['user_pass'] = wp_hash_password($userdata['user_pass']);
    233238        }
    234239
     240        // Update user data in the comments if display name, email, or URL has changed
     241        if ( ($user['display_name'] != $userdata['display_name']) || ($user['user_email'] != $userdata['user_email']) || ($user['user_url'] != $userdata['user_url']) )
     242                $wpdb->query("UPDATE $wpdb->comments SET comment_author = '{$userdata['display_name']}', comment_author_email = '{$userdata['user_email']}', comment_author_url = '{$userdata['user_url']}' WHERE user_id = '$ID'");
     243
    235244        // Merge old and new fields with new fields overwriting old ones.
    236245        $userdata = array_merge($user, $userdata);
    237246        $user_id = wp_insert_user($userdata);