get_users() WordPress Function

The get_users() function is a Wordpress function that allows you to get a list of users from the Wordpress database. You can use this function to get a list of all the users on your Wordpress site, or you can use it to get a list of specific users based on criteria that you specify.

get_users( array $args = array() ) #

Retrieves list of users matching criteria.


Description

Top ↑

See also


Top ↑

Parameters

$args

(array)(Optional) Arguments to retrieve users. See WP_User_Query::prepare_query() for more information on accepted arguments.

Default value: array()


Top ↑

Return

(array) List of users.


Top ↑

More Information

Return value is an array of IDs, stdClass objects, or WP_User objects, depending on the value of the ‘fields‘ parameter.

  • If ‘fields‘ is set to ‘all’ (default), or ‘all_with_meta’, it will return an array of WP_User objects.
  • If ‘fields‘ is set to an array of wp_users table fields, it will return an array of stdClass objects with only those fields.
  • If ‘fields‘ is set to any individual wp_users table field, an array of IDs will be returned.

Top ↑

Source

File: wp-includes/user.php

function get_users( $args = array() ) {

	$args                = wp_parse_args( $args );
	$args['count_total'] = false;

	$user_search = new WP_User_Query( $args );

	return (array) $user_search->get_results();
}


Top ↑

Changelog

Changelog
VersionDescription
3.1.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More