Page 1 of 1

Display Total Registered Members in Stats

Posted: Sat Oct 04, 2008 9:11 pm
by clublakers2
My users want to display the count of all registered members in the stats that appear on the index page (below who is online, above the footer).

Currently the "total members" count does not include inactive members. I would rather not activate all of those inactive members, but simply change the query to pull that registered member total.

Has anyone already come up with the solution?

Thanks

Re: Display Total Registered Members in Stats

Posted: Sat Oct 04, 2008 9:33 pm
by daroPL
Number of total users (active users) is storage in database (phpbb3_config table, num_users record). You can get number of total users in new SQL query or change value of num_users also in inactive users registration.
Better is first concept, so try this:
Open:
index.php

Find:

Code: Select all

$total_users    = $config['num_users']; 
Replace, with:

Code: Select all

//$total_users    = $config['num_users'];

$sql = 'SELECT COUNT(user_id) AS total_users
    FROM ' . USERS_TABLE;
$result = $db->sql_query($sql);
$total_users = (int) $db->sql_fetchfield('total_users'); 

Re: Display Total Registered Members in Stats

Posted: Sat Oct 04, 2008 10:45 pm
by clublakers2
daro, that worked perfectly. First virtual beer is on me tonight... well done sir.

Re: Display Total Registered Members in Stats

Posted: Fri Jun 12, 2009 2:54 pm
by amu1983
Great! That worked for me too.

The "Total members" number on the home page is kind-of a matter of pride for the webmaster. It makes sense to even include inactive users, as often, activating users manually might take days sometimes.. depending on how busy the moderators are.

Re: Display Total Registered Members in Stats

Posted: Tue Jul 14, 2009 1:01 pm
by RONVAN2000
daroPL wrote:Number of total users (active users) is storage in database (phpbb3_config table, num_users record). You can get number of total users in new SQL query or change value of num_users also in inactive users registration.
Better is first concept, so try this:
Open:
index.php

Find:

Code: Select all

$total_users    = $config['num_users']; 
Replace, with:

Code: Select all

//$total_users    = $config['num_users'];

$sql = 'SELECT COUNT(user_id) AS total_users
    FROM ' . USERS_TABLE;
$result = $db->sql_query($sql);
$total_users = (int) $db->sql_fetchfield('total_users'); 
Thank you very much.

Re: Display Total Registered Members in Stats

Posted: Fri Sep 17, 2010 2:44 pm
by noxxville
OK, so related question, but going the other way. On our forum, we want the "Total Members" to only count a specific group. We have guest accounts and don't want guests to be counted in the "Total Members" number. Any ideas?

Re: Display Total Registered Members in Stats

Posted: Sat Sep 18, 2010 2:49 pm
by daroPL
You must use the WHERE clause. Use the following code and put the group ID within.

Code: Select all

//$total_users    = $config['num_users'];

$sql = 'SELECT COUNT(user_id) AS total_users
    FROM ' . USERS_TABLE . '
    WHERE group_id = <group id here>';
$result = $db->sql_query($sql);
$total_users = (int) $db->sql_fetchfield('total_users');
$db->sql_freeresult($result); 

Re: Display Total Registered Members in Stats

Posted: Fri Oct 01, 2010 1:36 pm
by noxxville
daroPL wrote:You must use the WHERE clause. Use the following code and put the group ID within.

Code: Select all

//$total_users    = $config['num_users'];

$sql = 'SELECT COUNT(user_id) AS total_users
    FROM ' . USERS_TABLE . '
    WHERE group_id = <group id here>';
$result = $db->sql_query($sql);
$total_users = (int) $db->sql_fetchfield('total_users');
$db->sql_freeresult($result); 
Worked like a champ! Thanks!