How to get WordPress Username in Array format

The other answers are correct, but it’s possible to achive the same thing with less code using wp_list_pluck():

$users = get_users();
$user_names = wp_list_pluck( $users, 'display_name' );

wp_list_pluck() used that way will get the display_name field of all the users in an array without needing to do a loop.

Leave a Comment