How to get number of users online?

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
romeo_piter
Registered User
Posts: 129
Joined: Mon Nov 09, 2009 7:11 pm
Location: Paraguay

How to get number of users online?

Post by romeo_piter »

Hi. I hope someone can help.
I need to have number of users online for statistics block in my index_body template, only the number not the whole string which is {{ TOTAL_USERS }}. How can this be done?
User avatar
Mannix_
Registered User
Posts: 1919
Joined: Sun Oct 25, 2015 2:56 pm
Name: Matt

Re: How to get number of users online?

Post by Mannix_ »

Maybe tell us what is your end goal so we can help you better ;)
Did I helped You? Consider a donation.
New version of phpBB has been released? My styles aren't validated for it yet? Check my page for the latest downloads!
User avatar
halil16
Registered User
Posts: 1321
Joined: Fri Jul 24, 2020 11:30 pm
Location: Turkiye
Name: Halil

Re: How to get number of users online?

Post by halil16 »

Check the language file. ;)
My board: phpBB GroupO BeldeThatTowns*for sale*
Hire me for your phpBB board. ⭐
Introducing Mobile Upgrade! Make your phpBB board like an app! 📢
"The day we will need ideas more than possessions, we will find the secret to true wealth." - Peyami Safa
romeo_piter
Registered User
Posts: 129
Joined: Mon Nov 09, 2009 7:11 pm
Location: Paraguay

Re: How to get number of users online?

Post by romeo_piter »

Mannix_ wrote: Sun Apr 21, 2024 8:57 am Maybe tell us what is your end goal so we can help you better ;)
I give different information for registered users and for guest.
Regirestered user can see normal string: {{ TOTAL_USERS }} that is:
In total there are 534 users online :: 20 registered, 1 hidden and 513 guests (based on users active over the past 30 minutes)
This string is created in functions.php
For guests I don't want this string to be visible. The simplest way would be just to get rid of it, but I still need the number, that is:
534
from the string above without other things.

halil16 wrote: Sun Apr 21, 2024 1:37 pm Check the language file. ;)
This variable has nothing to do with language files as it is created in functions.php
User avatar
halil16
Registered User
Posts: 1321
Joined: Fri Jul 24, 2020 11:30 pm
Location: Turkiye
Name: Halil

Re: How to get number of users online?

Post by halil16 »

romeo_piter wrote: Mon Apr 22, 2024 4:42 am
This variable has nothing to do with language as it is created in fonctions.php
No, it's.

Open the /language/en/common.php

Find:

Code: Select all

	// "... :: x registered, y hidden and z guests"
	'ONLINE_USERS_TOTAL_GUESTS'	=> array(
		1	=> 'In total there is <strong>%1$d</strong> user online :: %2$s, %3$s and %4$s',
		2	=> 'In total there are <strong>%1$d</strong> users online :: %2$s, %3$s and %4$s',
	),
	
varan1.jpg

Change:

Code: Select all

	// "... :: x registered, y hidden and z guests"
	'ONLINE_USERS_TOTAL_GUESTS'	=> array(
		1	=> '<strong title="%2$s, %3$s and %4$s">%1$d</strong>',
		2	=> '<strong title="%2$s, %3$s and %4$s">%1$d</strong>',
	),
vara2.jpg

Okey? Many people will not recommend doing this, but it happens.
You do not have the required permissions to view the files attached to this post.
My board: phpBB GroupO BeldeThatTowns*for sale*
Hire me for your phpBB board. ⭐
Introducing Mobile Upgrade! Make your phpBB board like an app! 📢
"The day we will need ideas more than possessions, we will find the secret to true wealth." - Peyami Safa

Return to “phpBB Custom Coding”