Skip to content

Instantly share code, notes, and snippets.

@tiborp
Last active January 15, 2019 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tiborp/8a9b00cb1ceeafffb179c7cc7d75df61 to your computer and use it in GitHub Desktop.
Save tiborp/8a9b00cb1ceeafffb179c7cc7d75df61 to your computer and use it in GitHub Desktop.
<?php
// WP_User_Query arguments
$args = array(
'role' => 'subscriber',
'number' => '10',
'order' => 'ASC',
'orderby' => 'id',
);
// The User Query
$user_query = new WP_User_Query( $args );
// The User Loop
if ( ! empty( $user_query->results ) ) {
foreach ( $user_query->results as $user ) {
// do something
}
} else {
// no users found
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment