In this snippet I will show you how we can get WordPress users.
Get All WordPress users with administrator role
<?php
$users = get_users( array( 'role__in' => array( 'administrator') ) );
// Array of WP_User objects.
foreach ( $users as $user ) {
echo '<span>' . esc_html( $user->display_name ) . '</span>';
}
Get All Users
<?php
$users = get_users();
// Array of WP_User objects.
foreach ( $users as $user ) {
echo '<span>' . esc_html( $user->display_name ) . '</span>';
}