Hi!

I would like to find how many users my site has for some date. How can I find it? I found in module users that each registered user has own uid + created date, but I remove some accounts few times (problems with usernode/spam) in past (about 200 accounts) so e.g. uid 7000 doesn't mean that there were 7000 registered users on my site in that moment.

Do you think that there is some way how to find it? I triend to look at statistics module but I fonund no table in db with that name.

Thanks for your help
Igorik
http://www.somvprahe.sk

Comments

frock’s picture

i would also like to be able to see how many registered users there are on our drupal site, because people ask me ... & i'm kind of gobsmacked that there isn't an easy way to do this! i have hunted high & low within the core drupal installation, plus i've also been searching for modules that do a member count or some kind of member management. & why is there no way to search users from the list of users? many things that seem basic are missing ... :( ... or perhaps just not obvious???

ayesh’s picture

Perhaps a View to count them ?

// Create a View to list users and name it "count_users"
$my_view = views_get_view( 'count_users' );
$my_view->pager['items_per_page'] = 0;
$my_view->execute();
$my_view_sum= count($my_view->result);
print $my_view_sum;
john_b’s picture

on another thread which was also about the second poster's question http://drupal.org/node/51277#comment-5128602, see that thread for earlier versions of Drupal.

$count_users_tot = db_query('SELECT COUNT(uid) FROM {users} where status > 0')->fetchField();
print $count_users_tot;

(remove line break line 2-3!)
Obviously does not answer the OP question about count by date.

Digit Professionals specialising in Drupal, WordPress & CiviCRM support for publishers in non-profit and related sectors

igorik’s picture

yes, it was some time ago.
I am using currently

<?php
$total_users = db_result(db_query('SELECT COUNT(uid) FROM {users} WHERE status = 1'));
$output = 'We have already ' . $total_users . ' members.';
?>

how this "->fetchField()" works? is it good to use for some purpose?
Thanks

RKS’s picture

Wasn't your original question how to count user from a certain date? I.e. on October 5th, 2005 we had X amount of users.

I could be reading it wrong but it doesn't appear any of the solutions provide an answer to that question. Or maybe you just meant the current user count as of now?

ayesh’s picture

As I suggested Views solution above, we can push an argument to the View to get a date range or user-registered-date.

// Create a View to list users and name it "count_users"
$my_view = views_get_view( 'count_users' );
// Push arguments to the view. for a date range, push the date range.
$my_view->set_arguments( array( 1, 2, 3 ) );
$my_view->pager['items_per_page'] = 0;
$my_view->execute();
$my_view_sum= count($my_view->result);
print $my_view_sum;
john_b’s picture

Your reply is useful for me, although I just suggested a simple db query, as I am still learning this stuff. I think it there were two posters asking different questions, one wanting results with date and one without. But for both it certainly makes sense to use Views if Views is installed on the site.

Digit Professionals specialising in Drupal, WordPress & CiviCRM support for publishers in non-profit and related sectors