Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have been searching high and low for a way to count the amount of results from a get_users query.

Most of what I found is to count the total number of posts in a post query, but nothing for counting the total number of users in the get_users query.

Can someone point it out for me? Thanks a lot.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

when you use get_users() it retrieves an array of users matching the criteria given in $args which means you can simply use PHP's count() function e.g:

$users = get_users($args);
$number_of_users = count($users);
share|improve this answer
    
That answer is incorrect as get_users() only returns the requested number of results, i.e. 10, 20 etc... There may be more. –  unknowndomain Sep 12 '12 at 23:10
    
umm, that is true if you set the number parameter but if not (which obviously is the case here) then This answer is correct! –  Bainternet Sep 13 '12 at 8:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.