Ticket #28435: 28435.2.diff
File 28435.2.diff, 1.3 KB (added by , 10 years ago) |
---|
-
src/wp-includes/user.php
1887 1887 * @return int|WP_Error The updated user's ID or a WP_Error object if the user could not be updated. 1888 1888 */ 1889 1889 function wp_update_user($userdata) { 1890 if ( is_a( $userdata, 'stdClass' ) ) 1890 if ( is_a( $userdata, 'stdClass' ) ) { 1891 1891 $userdata = get_object_vars( $userdata ); 1892 elseif ( is_a( $userdata, 'WP_User' ) )1892 } elseif ( is_a( $userdata, 'WP_User' ) ) { 1893 1893 $userdata = $userdata->to_array(); 1894 } 1894 1895 1895 1896 $ID = (int) $userdata['ID']; 1896 1897 1897 1898 // First, get all of the original fields 1898 1899 $user_obj = get_userdata( $ID ); 1899 if ( ! $user_obj ) 1900 if ( ! $user_obj ) { 1900 1901 return new WP_Error( 'invalid_user_id', __( 'Invalid user ID.' ) ); 1902 } 1901 1903 1902 1904 $user = $user_obj->to_array(); 1903 1905 … … 1910 1912 $user = add_magic_quotes( $user ); 1911 1913 1912 1914 // If password is changing, hash it now. 1913 if ( ! empty( $userdata['user_pass'])) {1915 if ( ! empty( $userdata['user_pass'] ) && $userdata['user_pass'] !== $user_obj->user_pass ) { 1914 1916 $plaintext_pass = $userdata['user_pass']; 1915 1917 $userdata['user_pass'] = wp_hash_password($userdata['user_pass']); 1916 1918 }