From 8226fb2239d57bb56aed9a58a85ad55ae847faa1 Mon Sep 17 00:00:00 2001 From: ryan Date: Sun, 17 Jul 2005 19:55:19 +0000 Subject: [PATCH] get_usermeta() fixes. git-svn-id: http://svn.automattic.com/wordpress/trunk@2721 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/functions.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 640e530941..2d5a788e43 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -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 ) {