118 | | $user_id = wp_cache_get($user_login, 'userlogins'); |
119 | | $userdata = wp_cache_get($user_id, 'users'); |
120 | | |
121 | | if ( $userdata ) |
122 | | return $userdata; |
123 | | |
124 | | $user_login = $wpdb->escape($user_login); |
125 | | |
126 | | if ( !$user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE user_login = '$user_login'") ) |
127 | | return false; |
128 | | |
129 | | $wpdb->hide_errors(); |
130 | | $metavalues = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->usermeta WHERE user_id = '$user->ID'"); |
131 | | $wpdb->show_errors(); |
132 | | |
133 | | if ($metavalues) { |
134 | | foreach ( $metavalues as $meta ) { |
135 | | $value = maybe_unserialize($meta->meta_value); |
136 | | $user->{$meta->meta_key} = $value; |
137 | | |
138 | | // We need to set user_level from meta, not row |
139 | | if ( $wpdb->prefix . 'user_level' == $meta->meta_key ) |
140 | | $user->user_level = $meta->meta_value; |
141 | | } |
| 118 | if ( ! $user_id = wp_cache_get($user_login, 'userlogins') ) { |
| 119 | $user_login = $wpdb->escape($user_login); |
| 120 | $user_id = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_login = '$user_login' LIMIT 1"); |
| 121 | wp_cache_add($user_login, $user_id, 'userlogins'); |
144 | | // For backwards compat. |
145 | | if ( isset($user->first_name) ) |
146 | | $user->user_firstname = $user->first_name; |
147 | | if ( isset($user->last_name) ) |
148 | | $user->user_lastname = $user->last_name; |
149 | | if ( isset($user->description) ) |
150 | | $user->user_description = $user->description; |
151 | | |
152 | | wp_cache_add($user->ID, $user, 'users'); |
153 | | wp_cache_add($user->user_login, $user->ID, 'userlogins'); |
154 | | return $user; |
155 | | |
| 129 | return $userdata; |