I'm looking to create a list of all the users on my wordpress site with their email and role.
$blogusers = get_users();
// Array of WP_User objects.
foreach ( $blogusers as $user ) {
echo '<span>' . esc_html( $user->user_email ) . '</span>';
echo '<span>' . esc_html( $user->roles ) . '</span>';
}
This function is sort of what I am looking for but the user role displays as an array. Any thoughts on an easier way to do this?
Thanks