From 3a4570b0fc8b3d6339bef71d17d7701554e0bbf7 Mon Sep 17 00:00:00 2001 From: donncha Date: Fri, 12 Oct 2007 16:21:15 +0000 Subject: Merge with WP 2.3 - testing use only! Move pluggable functions out of wpmu-functions and into pluggable.php, fixes #439 git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1069 7be80a69-a1ef-0310-a953-fb0f7c49ff36 --- wp-includes/user.php | 77 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 70 insertions(+), 7 deletions(-) (limited to 'wp-includes/user.php') diff --git a/wp-includes/user.php b/wp-includes/user.php index f243fcc..1990a39 100644 --- a/wp-includes/user.php +++ b/wp-includes/user.php @@ -91,6 +91,9 @@ function get_usermeta( $user_id, $meta_key = '') { global $wpdb; $user_id = (int) $user_id; + if ( !$user_id ) + return false; + if ( !empty($meta_key) ) { $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); $metas = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->usermeta WHERE user_id = '$user_id' AND meta_key = '$meta_key'"); @@ -105,13 +108,8 @@ function get_usermeta( $user_id, $meta_key = '') { return ''; } - foreach ($metas as $index => $meta) { - @ $value = unserialize($meta->meta_value); - if ( $value === FALSE ) - $value = $meta->meta_value; - - $values[] = $value; - } + foreach ($metas as $meta) + $values[] = maybe_unserialize($meta->meta_value); if ( count($values) == 1 ) return $values[0]; @@ -179,4 +177,69 @@ function setup_userdata($user_id = '') { $user_identity = $user->display_name; } +function wp_dropdown_users( $args = '' ) { + global $wpdb; + $defaults = array( + 'show_option_all' => '', 'show_option_none' => '', + 'orderby' => 'display_name', 'order' => 'ASC', + 'include' => '', 'exclude' => '', + 'show' => 'display_name', 'echo' => 1, + 'selected' => 0, 'name' => 'user', 'class' => '' + ); + + $defaults['selected'] = is_author() ? get_query_var( 'author' ) : 0; + + $r = wp_parse_args( $args, $defaults ); + extract( $r, EXTR_SKIP ); + + $query = "SELECT * FROM $wpdb->users"; + + $query_where = array(); + + if ( is_array($include) ) + $include = join(',', $include); + $include = preg_replace('/[^0-9,]/', '', $include); // (int) + if ( $include ) + $query_where[] = "ID IN ($include)"; + + if ( is_array($exclude) ) + $exclude = join(',', $exclude); + $exclude = preg_replace('/[^0-9,]/', '', $exclude); // (int) + if ( $exclude ) + $query_where[] = "ID NOT IN ($exclude)"; + + if ( $query_where ) + $query .= " WHERE " . join(' AND', $query_where); + + $query .= " ORDER BY $orderby $order"; + + $users = $wpdb->get_results( $query ); + + $output = ''; + if ( !empty($users) ) { + $output = ""; + } + + $output = apply_filters('wp_dropdown_users', $output); + + if ( $echo ) + echo $output; + + return $output; +} + ?> -- cgit