User Online

Hello everyone,

 

I would like to know how to check if a specific user is online. Example: Check if user ID “ELC0003” is online.

 

Thanks.

<?php 
$allusers = StatsData::UsersOnline(); 
foreach ( $allusers as $user) {

echo $user->firstname.'<br>;

}

?>

This is just a simple code, I guess this should help.

31 minutes ago, LeonardIGO4036 said:

<?php 
$allusers = StatsData::UsersOnline(); 
foreach ( $allusers as $user) {

echo $user->firstname.'<br>;

}

?>

This is just a simple code, I guess this should help.

Thank you very much , but I would like to know one specific pilot.

So, I’m customizing Airmail for ElaSkin, and it will tell me if the user of the message is online. So from what I’m thinking I would have to get the ID of this pilot and continue, but I have no idea how.

23 hours ago, CarlosEduardo2409 said:

Thank you very much , but I would like to know one specific pilot.

So, I’m customizing Airmail for ElaSkin, and it will tell me if the user of the message is online. So from what I’m thinking I would have to get the ID of this pilot and continue, but I have no idea how.

Okay, now i understood. You just need to amend this code with an extra conditional statement. 

 

<?php 
$allusers = StatsData::UsersOnline(); 

$pilotid = (assign it here);
foreach ( $allusers as $user) {

if($user->pilotid == $pilotid) {

echo ‘Online’;

} else {

echo ‘Offline’; 

}

}

?>

That should be it! 

1 Like

6 minutes ago, LeonardIGO4036 said:

Okay, now i understood. You just need to amend this code with an extra conditional statement. 

 

<?php 
$allusers = StatsData::UsersOnline(); 

$pilotid = (assign it here);
foreach ( $allusers as $user) {

if($user->pilotid == $pilotid) {

echo ‘Online’;

} else {

echo ‘Offline’; 

}

}

?>

That should be it! 

Amazing! Thank you so much!!

1 minute ago, CarlosEduardo2409 said:

Amazing! Thank you so much!!

You’re welcome mate. All the best!