Skip to Content Skip to Menu

Userlist, only show users who are online.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48541
  • Thanks: 8290
  • Karma: 1445
5 years 1 month ago #314756 by krileon
Replied by krileon on topic Userlist, only show users who are online.
You can condition against the registerDate column in the _users table for that. You'll need to use the "u" table prefix (e.g. u.`registerDate`). See MYSQL documentation below regarding date functions.

dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html

How long they are considered new is entirely up to you. Example as follows compares registerDate to todays date minus 1 month.

Code:
u.`registerDate` >= DATE_SUB( NOW(), INTERVAL 1 MONTH )

That basically means "Has the user registered within 1 month from today? If so lets display them otherwise they are not new.".


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.

  • XBOOMX
  • XBOOMX
  • OFFLINE
  • Posts: 131
  • Thanks: 12
  • Karma: 0
5 years 1 month ago #314773 by XBOOMX
Replied by XBOOMX on topic Userlist, only show users who are online.
I did it this way:

( SELECT COUNT(*) FROM `#__session` AS s WHERE s.`userid` = u.`registerDate` >= DATE_SUB( NOW(), INTERVAL 1 MONTH ) > 0 AND ue.`cb_gender` = '[cb:if cb_gender="m"]f[cb:else]m[/cb:else][/cb:if]'

Unfortunately does not work :( What must I change?

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48541
  • Thanks: 8290
  • Karma: 1445
5 years 1 month ago #314778 by krileon
Replied by krileon on topic Userlist, only show users who are online.
Don't replace the user id check. You are just needing to add another AND statement to the query. See my below reply where I've added an AND statement. You'd add another for the registerDate check.

www.joomlapolis.com/forum/149-usage/241665-userlist-only-show-users-who-are-online?start=6#314748

Recommend the below resources to get you started on how to write SQL. We do not provide coding assistance here so I can not keep assisting you further with writing SQL.

Documentation
dev.mysql.com/doc/refman/5.7/en/entering-queries.html
dev.mysql.com/doc/refman/5.7/en/examples.html
dev.mysql.com/doc/refman/5.7/en/functions.html

Free Lessons
www.codecademy.com/learn/learn-sql
www.khanacademy.org/computing/computer-programming/sql
sqlbolt.com/
www.udemy.com/topic/sql/free/


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.
The following user(s) said Thank You: nant

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

Moderators: beatnantkrileon
Powered by Kunena Forum