Replace "Total Users" with "Active Users"

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Post Reply
tbehrens
Registered User
Posts: 26
Joined: Tue Jun 19, 2018 1:45 pm

Replace "Total Users" with "Active Users"

Post by tbehrens »

For 3.2.2, here's how to replace the "Total Users" count on the front page with "Active Users".

This goes back one month to count a user as "active"; set your own period as appropriate for your board.

Back up and then edit phpBB/index.php:

Find

Code: Select all

// Assign index specific vars
$template->assign_vars(array(
and insert before it

Code: Select all

// 2629743 is a month in seconds, 30.44 days
$since = time() - 2629743;
$sql = 'SELECT COUNT(user_id) AS total_users
    FROM ' . USERS_TABLE . '
    WHERE user_lastvisit > '.$since;
$result = $db->sql_query($sql);
$total_users = (int) $db->sql_fetchfield('total_users');
$db->sql_freeresult($result); 
Then find

Code: Select all

 'TOTAL_USERS'   => $user->lang('TOTAL_USERS', (int) $config['num_users']),
and change it to read

Code: Select all

//      'TOTAL_USERS'   => $user->lang('TOTAL_USERS', (int) $config['num_users']),
        'TOTAL_USERS'   => $user->lang('TOTAL_USERS', (int) $total_users),
Back up and edit each phpBB/language/[lang-dir]/common.php:

Find

Code: Select all

        'TOTAL_USERS'           => array(
                2       => 'Total members <strong>%d</strong>',
        ),
or the language equivalent and change it to

Code: Select all

        'TOTAL_USERS'           => array(
                2       => 'Active members <strong>%d</strong>',
        ),
or the language equivalent.

That's it. You now have an overview of how many of your members have logged in during the past N days, depending on what you set $since to.
User avatar
stevemaury
Support Team Member
Support Team Member
Posts: 52768
Joined: Thu Nov 02, 2006 12:21 am
Location: The U.P.
Name: Steve
Contact:

Re: Replace "Total Users" with "Active Users"

Post by stevemaury »

Well, in phpBB nomenclature, an "active user" is a user who is not "inactive", so this really shows more like "Recent users".
I can stop all your spam. I can upgrade or update your Board. PM or email me. (Paid support)
Post Reply

Return to “phpBB Custom Coding”