Display Total Registered Members in Stats

Looking for a MOD? Have a MOD request? Post here for help. (Note: This forum is community supported; phpBB does not have official MOD authors)
Get Involved
Locked
clublakers2
Registered User
Posts: 13
Joined: Mon Oct 09, 2006 3:16 am

Display Total Registered Members in Stats

Post 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
User avatar
daroPL
Registered User
Posts: 515
Joined: Tue Mar 27, 2007 11:58 am
Location: Poznan, Poland
Name: Darek
Contact:

Re: Display Total Registered Members in Stats

Post 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'); 
clublakers2
Registered User
Posts: 13
Joined: Mon Oct 09, 2006 3:16 am

Re: Display Total Registered Members in Stats

Post by clublakers2 »

daro, that worked perfectly. First virtual beer is on me tonight... well done sir.
amu1983
Registered User
Posts: 22
Joined: Wed Sep 10, 2008 4:45 am
Contact:

Re: Display Total Registered Members in Stats

Post 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.
RONVAN2000
Registered User
Posts: 26
Joined: Thu Jan 29, 2004 8:00 pm

Re: Display Total Registered Members in Stats

Post 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.
noxxville
Registered User
Posts: 12
Joined: Thu Mar 27, 2008 5:21 pm

Re: Display Total Registered Members in Stats

Post 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?
User avatar
daroPL
Registered User
Posts: 515
Joined: Tue Mar 27, 2007 11:58 am
Location: Poznan, Poland
Name: Darek
Contact:

Re: Display Total Registered Members in Stats

Post 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); 
noxxville
Registered User
Posts: 12
Joined: Thu Mar 27, 2008 5:21 pm

Re: Display Total Registered Members in Stats

Post 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!
Locked

Return to “[3.0.x] MOD Requests”