How to loop through each user id?
-
26-04-2021 - |
Question
The functions that I am aware of:
WP_User
and
wp_get_current_user
seem to only get the user object of the current user. As an administrator, if I want to display certain profile information in a table from each user, how can I loop through the ids?
Can this be done with WP template tags or should I resort to SQL?
Thanks in advance
Solution
How about using get_users()
? You probably don't even need parameters for it, default behavior should be just what you're looking for.
OTHER TIPS
get_users() documentation has moved to a new location from the codex link provided by mor7ifer. Here is the new link to save an extra click:
get_users() documentation: https://developer.wordpress.org/reference/functions/get_users/
I don't have the reputation to comment yet, otherwise would have just asked to change the link in the existing solution.