Hello!
I’m looking or the aid of a Who’s online scripts. Is that possible with Kirby? Displays which users are online now?
Thanks for help
Hello!
I’m looking or the aid of a Who’s online scripts. Is that possible with Kirby? Displays which users are online now?
Thanks for help
I think the most simple solution would be to save the online status of each user in the User object, as an additional “is_online” field or something similar. Then you could just filter all users by this field using $users->filterBy('is_online', 'online')
. The only negative thing might be the need to update the user object each time someone logs in/out. This could be achieved with the user’s update function.
Thanks!
Can I add $users->filterBy into the footer?
When I to this, than I became a error:
Fatal error: Call to a member function filterBy() on a non-object in …
You have to define $users
first with $site->users()
: http://getkirby.com/docs/cheatsheet/site/users
Okay $user->filterBy(‘is_online’, ‘online’) work.
But I can’t see any online User…
Do you update your user information on login/logout to set the is_online
field as @jakobploens suggested?
Yes I have this do…
So what does $users->filterBy('is_online', 'online')
return if a user is currently logged in?
I all User’s there are online…?
So what is the problem? I don’t quite understand what’s missing.
is_online
via controlleris_online
is_online
via controllerI think I get the idea (I’ll have to try it).
But kirby logs out the user automatically from time to time (not sure about the interval).
You can change the interval from your Kirby configuration.