May 2017
Beginner to intermediate
536 pages
14h 25m
English
The WP_User_Query class is used to query user-related data from the WordPress database. Basically, this class uses the wp_users and the wp_usermeta tables for its queries. This is the second-most-used class after WP_Query. Let's take a look at the basic usage of this class in the following code:
$user_query = new WP_User_Query( array( 'role' => 'Administrator' ); if ( ! empty( $user_query->results ) ) { foreach ( $user_query->results as $user ) { // display user details } }
The WP_User_Query class takes an array of arguments for filtering users based on various criteria. In this scenario, we have filtered users with an administrator role. The following are some of the filtering methods that we can use with ...
Read now
Unlock full access