From b2d8dd8e8380cbf9507340f55e3c4e8add161cda Mon Sep 17 00:00:00 2001 From: greenshady Date: Sun, 28 Nov 2010 20:34:13 +0000 Subject: [PATCH] Use the get_users() WP 3.1 function for listing users. git-svn-id: http://svn.locallylost.com/plugins/members/trunk@499 dba0f204-706d-4bc1-bc29-8b92e0485636 --- functions.php | 92 +++++++-------------------------------------------- 1 file changed, 12 insertions(+), 80 deletions(-) diff --git a/functions.php b/functions.php index 2ba3a81..e969e04 100644 --- a/functions.php +++ b/functions.php @@ -22,8 +22,6 @@ function members_login_form() { /** * Creates the login form. - * @todo Make each section customizable. - * @todo Clean up. * * @since 0.1.0 * @deprecated 0.2.0 Use wp_login_form() instead. @@ -33,106 +31,40 @@ function members_get_login_form( $args = array() ) { } /** - * Function for listing users like the WordPress function currently use for authors. - * This function is based off wp_dropdown_users() and wp_list_authors(). It is my - * hope that a wp_list_users() function eventually exists and this is no longer relevant. + * Function for listing users like the WordPress function currently uses for authors. * - * @todo Allow the input of a role to limit the list. + * Eventually, I hope to remove this function in favor of wp_list_users(): + * @link http://core.trac.wordpress.org/ticket/15145 * * @since 0.1 - * @param $order string ASC or DESC order. - * @param $orderby string display_name, id, user_login - * @param $include string IDs of users to include. - * @param $exclude string IDs of users to exclude. - * @param $limit int Number of users to list. - * @param $show_fullname bool Whether to show users' full name (defaults to display name). - * @param $echo bool Whether to print the list or return for use in a function. + * @uses get_users() */ function members_list_users( $args = array() ) { - global $wpdb; - - $defaults = array( - 'order' => 'ASC', - 'orderby' => 'display_name', - 'include' => '', - 'exclude' => '', - //'role' => '', - 'limit' => '', - //'optioncount' => false, - 'show_fullname' => true, - //'exclude_empty' => false, - //'exclude_admin' => true, - 'echo' => true, - ); - - $r = wp_parse_args( $args, $defaults ); - - $r = apply_filters( 'members_list_users_args', $r ); - - 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"; - - if ( '' != $limit ) { - $limit = absint( $limit ); - $query .= ' LIMIT ' . $limit; - } - - $users = $wpdb->get_results( $query ); $output = ''; + $users = get_users( $args ); if ( !empty( $users ) ) { - foreach ( (array) $users as $user ) { - - $user->ID = (int) $user->ID; - - $author = get_userdata( $user->ID ); + $output .= ''; } $output = apply_filters( 'members_list_users', $output ); - if ( !$echo ) + if ( empty( $args['echo'] ) ) return $output; echo $output;