Title: wp_list_users
Published: February 3, 2022
Last modified: February 24, 2026

---

# wp_list_users( string|array $args = array() ): string|null

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/wp_list_users/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/wp_list_users/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_list_users/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/wp_list_users/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/wp_list_users/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_list_users/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/wp_list_users/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_list_users/?output_format=md#wp--skip-link--target)

Lists all the users of the site, with several options available.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_list_users/?output_format=md#parameters)󠁿

 `$args`string|arrayoptional

Array or string of default arguments.

 * `orderby` string
 * How to sort the users. Accepts `'nicename'`, `'email'`, `'url'`, `'registered'`,`'
   user_nicename'`, `'user_email'`, `'user_url'`, `'user_registered'`, `'name'`,`'
   display_name'`, `'post_count'`, `'ID'`, `'meta_value'`, `'user_login'`. Default`'
   name'`.
 * `order` string
 * Sorting direction for $orderby. Accepts `'ASC'`, `'DESC'`. Default `'ASC'`.
 * `number` int
 * Maximum users to return or display. Default empty (all users).
 * `exclude_admin` bool
 * Whether to exclude the `'admin'` account, if it exists. Default false.
 * `show_fullname` bool
 * Whether to show the user’s full name. Default false.
 * `feed` string
 * If not empty, show a link to the user’s feed and use this text as the alt parameter
   of the link.
 * `feed_image` string
 * If not empty, show a link to the user’s feed and use this image URL as clickable
   anchor.
 * `feed_type` string
 * The feed type to link to, such as `'rss2'`. Defaults to default feed type.
 * `echo` bool
 * Whether to output the result or instead return it. Default true.
 * `style` string
 * If `'list'`, each user is wrapped in an `<li>` element, otherwise the users will
   be separated by commas.
 * `html` bool
 * Whether to list the items in HTML form or plaintext. Default true.
 * `exclude` string
 * An array, comma-, or space-separated list of user IDs to exclude.
 * `include` string
 * An array, comma-, or space-separated list of user IDs to include.

Default:`array()`

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_list_users/?output_format=md#return)󠁿

 string|null The output if echo is false. Otherwise null.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_list_users/?output_format=md#source)󠁿

    ```php
    function wp_list_users( $args = array() ) {
    	$defaults = array(
    		'orderby'       => 'name',
    		'order'         => 'ASC',
    		'number'        => '',
    		'exclude_admin' => true,
    		'show_fullname' => false,
    		'feed'          => '',
    		'feed_image'    => '',
    		'feed_type'     => '',
    		'echo'          => true,
    		'style'         => 'list',
    		'html'          => true,
    		'exclude'       => '',
    		'include'       => '',
    	);

    	$parsed_args = wp_parse_args( $args, $defaults );

    	$return = '';

    	$query_args           = wp_array_slice_assoc( $parsed_args, array( 'orderby', 'order', 'number', 'exclude', 'include' ) );
    	$query_args['fields'] = 'ids';

    	/**
    	 * Filters the query arguments for the list of all users of the site.
    	 *
    	 * @since 6.1.0
    	 *
    	 * @param array $query_args  The query arguments for get_users().
    	 * @param array $parsed_args The arguments passed to wp_list_users() combined with the defaults.
    	 */
    	$query_args = apply_filters( 'wp_list_users_args', $query_args, $parsed_args );

    	$users = get_users( $query_args );

    	foreach ( $users as $user_id ) {
    		$user = get_userdata( $user_id );

    		if ( $parsed_args['exclude_admin'] && 'admin' === $user->display_name ) {
    			continue;
    		}

    		if ( $parsed_args['show_fullname'] && '' !== $user->first_name && '' !== $user->last_name ) {
    			$name = sprintf(
    				/* translators: 1: User's first name, 2: Last name. */
    				_x( '%1$s %2$s', 'Display name based on first name and last name' ),
    				$user->first_name,
    				$user->last_name
    			);
    		} else {
    			$name = $user->display_name;
    		}

    		if ( ! $parsed_args['html'] ) {
    			$return .= $name . ', ';

    			continue; // No need to go further to process HTML.
    		}

    		if ( 'list' === $parsed_args['style'] ) {
    			$return .= '<li>';
    		}

    		$row = $name;

    		if ( ! empty( $parsed_args['feed_image'] ) || ! empty( $parsed_args['feed'] ) ) {
    			$row .= ' ';
    			if ( empty( $parsed_args['feed_image'] ) ) {
    				$row .= '(';
    			}

    			$row .= '<a href="' . get_author_feed_link( $user->ID, $parsed_args['feed_type'] ) . '"';

    			$alt = '';
    			if ( ! empty( $parsed_args['feed'] ) ) {
    				$alt  = ' alt="' . esc_attr( $parsed_args['feed'] ) . '"';
    				$name = $parsed_args['feed'];
    			}

    			$row .= '>';

    			if ( ! empty( $parsed_args['feed_image'] ) ) {
    				$row .= '<img src="' . esc_url( $parsed_args['feed_image'] ) . '" style="border: none;"' . $alt . ' />';
    			} else {
    				$row .= $name;
    			}

    			$row .= '</a>';

    			if ( empty( $parsed_args['feed_image'] ) ) {
    				$row .= ')';
    			}
    		}

    		$return .= $row;
    		$return .= ( 'list' === $parsed_args['style'] ) ? '</li>' : ', ';
    	}

    	$return = rtrim( $return, ', ' );

    	if ( ! $parsed_args['echo'] ) {
    		return $return;
    	}
    	echo $return;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/user.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/user.php#L913)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/user.php#L913-L1018)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/wp_list_users/?output_format=md#hooks)󠁿

 [apply_filters( ‘wp_list_users_args’, array $query_args, array $parsed_args )](https://developer.wordpress.org/reference/hooks/wp_list_users_args/)

Filters the query arguments for the list of all users of the site.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_list_users/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_array_slice_assoc()](https://developer.wordpress.org/reference/functions/wp_array_slice_assoc/)`wp-includes/functions.php` |

Extracts a slice of an array, given a list of keys.

  | 
| [get_author_feed_link()](https://developer.wordpress.org/reference/functions/get_author_feed_link/)`wp-includes/link-template.php` |

Retrieves the feed link for a given author.

  | 
| [get_users()](https://developer.wordpress.org/reference/functions/get_users/)`wp-includes/user.php` |

Retrieves list of users matching criteria.

  | 
| [_x()](https://developer.wordpress.org/reference/functions/_x/)`wp-includes/l10n.php` |

Retrieves translated string with gettext context.

  | 
| [esc_attr()](https://developer.wordpress.org/reference/functions/esc_attr/)`wp-includes/formatting.php` |

Escaping for HTML attributes.

  | 
| [esc_url()](https://developer.wordpress.org/reference/functions/esc_url/)`wp-includes/formatting.php` |

Checks and cleans a URL.

  | 
| [get_userdata()](https://developer.wordpress.org/reference/functions/get_userdata/)`wp-includes/pluggable.php` |

Retrieves user info by user ID.

  | 
| [wp_parse_args()](https://developer.wordpress.org/reference/functions/wp_parse_args/)`wp-includes/functions.php` |

Merges user defined arguments into defaults array.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  |

[Show 6 more](https://developer.wordpress.org/reference/functions/wp_list_users/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/wp_list_users/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_list_users/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.9.0](https://developer.wordpress.org/reference/since/5.9.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/wp_list_users/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 2 content](https://developer.wordpress.org/reference/functions/wp_list_users/?output_format=md#comment-content-6829)
 2.    [Rafa Carvalhido](https://profiles.wordpress.org/rafacarvalhido/)  [  2 years ago  ](https://developer.wordpress.org/reference/functions/wp_list_users/#comment-6829)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_list_users%2F%23comment-6829)
     Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_list_users%2F%23comment-6829)
 4.  Produces a list of users by user display_name.
 5.      ```php
         wp_list_users();
         ```
     
 6.  or
 7.      ```php
         $users = wp_list_users( array( 'echo' => false ) );
         echo $users;
         ```
     
 8.  Results:
 9.   * Admin
      * Rafa Carvalhido
      * User 3
      * User Userlastname
 10.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_list_users%2F%3Freplytocom%3D6829%23feedback-editor-6829)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_list_users%2F)
before being able to contribute a note or feedback.