Permalink
Browse files

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
  • Loading branch information...
1 parent eb823a9 commit b2d8dd8e8380cbf9507340f55e3c4e8add161cda greenshady committed Nov 28, 2010
Showing with 12 additions and 80 deletions.
  1. +12 −80 functions.php
View
@@ -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 .= '<ul class="xoxo members-list-users">';
- $name = $author->display_name;
+ foreach ( $users as $user ) {
- if ( $show_fullname && ($author->first_name != '' && $author->last_name != '') )
- $name = "$author->first_name $author->last_name";
+ $url = get_author_posts_url( $author->ID, $author->user_nicename );
$class = "user-{$user->ID}";
-
if ( is_author( $user->ID ) )
$class .= ' current-user';
- if ( $hide_empty )
- $output .= "<li class='$class'>$name</li>\n";
- else
- $output .= "<li class='$class'><a href='" . get_author_posts_url( $author->ID, $author->user_nicename ) . "' title='" . sprintf(__("Posts by %s"), esc_attr( $author->display_name ) ) . "'>$name</a></li>\n";
+ $output .= "<li class='{$class}'><a href='{$url}' title='" . esc_attr( $user->display_name ) . "'>{$user->display_name}</a></li>\n";
}
+
+ $output .= '</ul>';
}
$output = apply_filters( 'members_list_users', $output );
- if ( !$echo )
+ if ( empty( $args['echo'] ) )
return $output;
echo $output;

0 comments on commit b2d8dd8

Please sign in to comment.