Forum Discussion
- mcalcaterraKhoros Alumni (Retired)
Hi waldemarhelm something like this will print out a list of the ids of users that have the administrator role with a link to their profile page
<#assign admins = (liql("SELECT id, online_status, href FROM users WHERE roles.id='t:Administrator'").data.items)![] /> <#list admins as admin> <#if admin.online_status = 'online'> <a href="${admin.href}">${admin.id}</a> </#if> </#list>
you should be able to use this as a base template and query for the avatars as well and display that instead of the ids.
Keep in mind this will return 25 users, you can increase/reduce the limit as needed
Hi mcalcaterra I think you can improve your liql by ordering by last_visit_time to get a better change to find online users. Sadly we have not the constraint option for online_status so we have to use such a workaround.
SELECT id, online_status, href FROM users WHERE roles.id='t:Administrator' ORDER BY last_visit_time DESC
- waldemarhelmDirector
mcalcaterra Thank you. We will try this out.
waldemarhelm
Not feasible becuase online_status constraint can't be used with any other constraints. You can share your ideas/need under Idea section.- lukBoss
Well, a query like the one provided by steffenschoene this will give you data to work with
SELECT id, online_status, last_visit_time, href FROM users WHERE roles.name='Administrator' AND last_visit_time > 2023-02-25T00:00:00.000-07:00 ORDER BY last_visit_time DESC LIMIT 100
the problem is that the field "online_status" is absurdly unreliable, i just checked in one of our communities, there are "online" users with a last_visit_time in 2020 🙄...
so do NOT rely on what that field says, so i'd probably use a combination of "online" and "last_visit_time" to filter out a more reasonable subset of users that might be online, e.g. like i adapted the query above. Still doesn't mean that user is still online though... I assume online_status is determined by session and maybe if someone checks "remember me" when logging in, the session does not expire for a long time, so that user just "stays" online in the eyes of Khoros. But that's only speculation.
Related Content
- 4 years ago
- 4 years agoInactive User