Skip to Content Skip to Menu

🎃 Happy Halloween! Treat yourself with an awesome discount on memberships! Get 20% off now with code SPOOKY-2024!

[SOLVED] user list, online only or, online and then last online

  • smFruen
  • smFruen
  • OFFLINE
  • Posts: 116
  • Thanks: 5
  • Karma: 3
8 years 1 month ago - 8 years 1 month ago #285634 by smFruen
this code works fine, and show everyone who is online.
but it also shows those who are not online in order of oldest first

( ( SELECT MAX( s.`time` ) FROM `#__session` AS s WHERE s.`userid` = u.`id` AND s.`guest` = 0 ) IS NULL )


Can i make a code which only show those online.

Or

one showing them that are online first, and then afterwards those who were last online

Attachments:
Last edit: 8 years 1 month ago by krileon. Reason: Added [SOLVED] tag to subject

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48454
  • Thanks: 8280
  • Karma: 1443
8 years 1 month ago #285636 by krileon
You added an advanced sort, not an advanced filter. This means it's adding your custom query to the Order By of the userlist query and not the WHERE. If you want online users ordered first then the below should work fine.

Code:
( SELECT MAX( s.`time` ) FROM `#__session` AS s WHERE s.`userid` = u.`id` AND s.`guest` = 0 ) DESC

The below can be used to filter the userlist to online users only.

Code:
( SELECT COUNT(*) FROM `#__session` AS s WHERE s.`userid` = u.`id` AND s.`guest` = 0 ) > 0


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • smFruen
  • smFruen
  • OFFLINE
  • Posts: 116
  • Thanks: 5
  • Karma: 3
8 years 1 month ago #285639 by smFruen
Works fine now which only show online

thanks.

can i also make one, where I filters, online first and then show those who were online last ?

Please Log in or Create an account to join the conversation.

  • smFruen
  • smFruen
  • OFFLINE
  • Posts: 116
  • Thanks: 5
  • Karma: 3
8 years 1 month ago #285640 by smFruen
want online users ordered first then lastvisitdate descending , in one list

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48454
  • Thanks: 8280
  • Karma: 1443
8 years 1 month ago #285686 by krileon
Then you need to do that in an advanced order by, which combines the order by I've already provided you with an addition of lastvisitdate. Below will probably work.

Code:
( SELECT MAX( s.`time` ) FROM `#__session` AS s WHERE s.`userid` = u.`id` AND s.`guest` = 0 ) DESC, u.`lastvisitdate` DESC


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • smFruen
  • smFruen
  • OFFLINE
  • Posts: 116
  • Thanks: 5
  • Karma: 3
8 years 1 month ago #285698 by smFruen
smiles, thanks it works fine.


thanks

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum