By fuzzion on
How can I count/display the number of profiles (members) into a page?
Like this:
"Currently we have X members"
Using PHP snippets or is there any other way?
I am a Drupal newbie..
Thanks
How can I count/display the number of profiles (members) into a page?
Like this:
"Currently we have X members"
Using PHP snippets or is there any other way?
I am a Drupal newbie..
Thanks
Comments
SQL is your best friend ;-)
Do you want members currently visiting a specific page or just the number of users on your site? There is a block in the standard installation that shows the active users of your site (go to admin->build->blocks and enable it. This doesn't show you the total number...
If you want that to happen you can create a page (or any other type that can hav a body with PHP and enter the following:
We have <?php print db_result(db_query('SELECT COUNT(uid) FROM {users} WHERE uid > 0 AND status = 1')); ?> registred users on this siteThe status=1 is to count non-blocked users only
If you want just logged in users it gets a bit trickier...
...but there is already a function
sess_count($timestamp = 0, $anonymous = true)that counts sessions. Have a look att session.inc in the includes directory.Thanks
That's perfect!
Tack Håkan :)