Ticket #2134: pluggable-functions.php.diff
File pluggable-functions.php.diff, 1.8 KB (added by , 19 years ago) |
---|
-
wp-includes/pluggable-functions.php
28 28 endif; 29 29 30 30 if ( !function_exists('get_userdata') ) : 31 function get_userdata( $user_id ) {31 function get_userdata( $user_id, $user_row=false ) { 32 32 global $wpdb; 33 if ( !$user_row ) { 33 34 $user_id = (int) $user_id; 34 35 if ( $user_id == 0 ) 35 36 return false; … … 41 42 42 43 if ( !$user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE ID = '$user_id' LIMIT 1") ) 43 44 return false; 45 } else 46 $user = $user_row; 44 47 45 48 $wpdb->hide_errors(); 46 49 $metavalues = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->usermeta WHERE user_id = '$user_id'"); … … 83 86 $userdata = wp_cache_get($user_login, 'userlogins'); 84 87 if ( $userdata ) 85 88 return $userdata; 86 87 if ( !$user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE user_login = '$user_login'") ) 89 elseif ( $user = $wpdb->get_var("SELECT * FROM $wpdb->users WHERE user_login = '$user_login'") ) 90 return get_userdata($user->$ID, $user); 91 else 88 92 return false; 89 90 $wpdb->hide_errors();91 $metavalues = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->usermeta WHERE user_id = '$user->ID'");92 $wpdb->show_errors();93 94 if ($metavalues) {95 foreach ( $metavalues as $meta ) {96 @ $value = unserialize($meta->meta_value);97 if ($value === FALSE)98 $value = $meta->meta_value;99 $user->{$meta->meta_key} = $value;100 101 // We need to set user_level from meta, not row102 if ( $wpdb->prefix . 'user_level' == $meta->meta_key )103 $user->user_level = $meta->meta_value;104 }105 }106 107 wp_cache_add($user->ID, $user, 'users');108 wp_cache_add($user->user_login, $user, 'userlogins');109 110 return $user;111 112 93 } 113 94 endif; 114 95