get_usermeta() fixes.

git-svn-id: http://svn.automattic.com/wordpress/trunk@2721 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2005-07-17 19:55:19 +00:00
parent 1e5d0b0736
commit 8226fb2239
1 changed files with 10 additions and 8 deletions

View File

@ -1952,21 +1952,23 @@ function get_usermeta( $user_id, $meta_key = '') {
if ( !empty($meta_key) ) {
$meta_key = preg_replace('|a-z0-9_|i', '', $meta_key);
$metas = $wpdb->get_results("SELECT * FROM $wpdb->usermeta WHERE user_id = '$user_id' AND meta_key = '$meta_key'");
$metas = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->usermeta WHERE user_id = '$user_id' AND meta_key = '$meta_key'");
} else {
$metas = $wpdb->get_results("SELECT * FROM $wpdb->usermeta WHERE user_id = '$user_id'");
$metas = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->usermeta WHERE user_id = '$user_id'");
}
foreach ($metas as $index => $meta) {
@ $value = unserialize($meta->meta_key);
if ($value !== FALSE)
$metas[$index]->meta_key = $value;
@ $value = unserialize($meta->meta_value);
if ($value === FALSE)
$value = $meta->meta_value;
$values[] = $value;
}
if ( !empty($meta_key) )
return $metas[0];
if ( count($values) == 1 )
return $values[0];
else
return $metas;
return $values;
}
function update_usermeta( $user_id, $meta_key, $meta_value ) {