Online/offline status displayed by an image?

Fayna - June 2, 2008 - 06:11
Project:User Stats
Version:6.x-1.x-dev
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed
Description

I've been looking for ways to do this---would User Stats enable me to do it? i.e., show an "Online now" image next to the username of a node author.

#1

Liam McDermott - June 2, 2008 - 23:24
Status:active» fixed

Yes. See the documentation.

#2

Fayna - June 3, 2008 - 05:07

Oh geez, I'm a doofus. Thanks. :-)

#3

Liam McDermott - June 3, 2008 - 07:25

Hehehe. No worries. :D

#4

Fayna - June 4, 2008 - 04:33

Sorry >.<, I got it working great, but is there a way to only show the online image and no offline image?

#5

Liam McDermott - June 4, 2008 - 09:59

is there a way to only show the online image and no offline image?

Off the top of my head, and totally untested, but try this:

<?php if (user_stats_get_stats('online', $node->uid)): ?>
<img src="<?php print base_path() . path_to_theme() ?>/online.png" alt="User is online" />
<?php endif; ?>

#6

Fayna - June 4, 2008 - 20:28

Yay thank you!! It worked!

#7

Anonymous (not verified) - June 18, 2008 - 20:32
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

#8

czeky - January 2, 2009 - 22:04

hi, any chance to implement this into user-profile.tpl.php? (located in modules/user)? it would be nice to have online/offline status right in user profile

Online:

<?php
print (user_stats_get_stats('online', $node->uid) ? 'yes' : 'no');
?>

is not working of course

btw... print base_path() . path_to_theme() unfortunatelly prints out "modules/user" path to modules directory

many thanx

#9

jakewalk - September 14, 2009 - 16:55

I am confused. Under which circumstances is that supposed to work? Because basically the module seems to work perfectly (the "Is online"-filter in Views for example works). I tried to add the following to the node.tpl.php:

Online:

<?php
print (user_stats_get_stats('online', $node->uid) ? 'yes' : 'no');
?>

But that doesn't work, all users appear as offline although I have a block at the right side that clearly shows that the module is correctly detecting online users. And to complete my confusion this piece of code works:

Post count:

<?php
print user_stats_get_stats('post_count', $node->uid);
?>

How can I solve that?

Regards,
jakewalk

 
 

Drupal is a registered trademark of Dries Buytaert.