Fetch all users by role

PHOTO EMBED

Tue Mar 15 2022 12:48:38 GMT+0000 (UTC)

Saved by @zildjianjaxolis #wordpress #php #woocommerce

<?php

$args = array(
  'role'    => 'customer',
  'orderby' => 'user_nicename',   
  'order'   => 'ASC'
);
$users = get_users( $args );

echo '<ul>';
foreach ( $users as $user ) {
	echo '<li>' . esc_html( $user->display_name ) . '[' . esc_html( $user->user_email ) . ']</li>';
}
echo '</ul>';
content_copyCOPY