Ticket #17009: wp_update_user.patch
File wp_update_user.patch, 1.7 KB (added by , 14 years ago) |
---|
-
user.php
1542 1542 * @param array $userdata An array of user data. 1543 1543 * @return int The updated user's ID. 1544 1544 */ 1545 function wp_update_user( $userdata) {1545 function wp_update_user( $userdata ) { 1546 1546 $ID = (int) $userdata['ID']; 1547 1547 1548 1548 // First, get all of the original fields 1549 $user = get_userdata( $ID);1549 $user = get_userdata( $ID ); 1550 1550 1551 // Escape data pulled from DB. 1552 $user = add_magic_quotes(get_object_vars($user)); 1553 1554 // If password is changing, hash it now. 1555 if ( ! empty($userdata['user_pass']) ) { 1556 $plaintext_pass = $userdata['user_pass']; 1557 $userdata['user_pass'] = wp_hash_password($userdata['user_pass']); 1551 // Escape data pulled from DB if any data was pulled. Otherwise make the variable an empty array to use with array_merge() later on 1552 if( $user ) { 1553 $user = add_magic_quotes( get_object_vars( $user ) ); 1554 } else { 1555 $user = array(); 1558 1556 } 1557 1558 wp_cache_delete( $user[ 'user_email' ], 'useremail' ); 1559 1559 1560 wp_cache_delete($user[ 'user_email' ], 'useremail');1561 1562 1560 // Merge old and new fields with new fields overwriting old ones. 1563 $userdata = array_merge( $user, $userdata);1564 $user_id = wp_insert_user( $userdata);1561 $userdata = array_merge( $user, $userdata ); 1562 $user_id = wp_insert_user( $userdata ); 1565 1563 1566 1564 // Update the cookies if the password changed. 1567 1565 $current_user = wp_get_current_user(); 1568 if ( $current_user->id == $ID ) { 1569 if ( isset($plaintext_pass) ) { 1570 wp_clear_auth_cookie(); 1571 wp_set_auth_cookie($ID); 1572 } 1566 if ( $current_user->id == $ID && ! empty( $userdata['user_pass'] ) ) { 1567 wp_clear_auth_cookie(); 1568 wp_set_auth_cookie($ID); 1573 1569 } 1574 1570 1575 1571 return $user_id;