Skip to Content Skip to Menu

🌲 Merry Christmas! Great savings on Professional and Developer Memberships! Get 25% off now with code XMAS-2024!

Userlist, only show users who are online.

  • XBOOMX
  • XBOOMX
  • OFFLINE
  • Posts: 131
  • Thanks: 12
  • Karma: 0
5 years 2 months ago #314737 by XBOOMX
Replied by XBOOMX on topic Userlist, only show users who are online.
cb_gender is a dropdown. How should I add the values to the database query?



Can someone tell me how the database query then have to look complete?

Thank you very much
Attachments:

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

  • Astrid
  • Astrid
  • OFFLINE
  • Posts: 183
  • Thanks: 68
  • Karma: 10
5 years 2 months ago #314738 by Astrid
Replied by Astrid on topic Userlist, only show users who are online.
Code:
( SELECT COUNT(*) FROM `#__session` AS s WHERE s.`userid` = u.`id` AND s.`guest` = 0 ) > 0 AND ue.`cb_gender` = 'm'
The following user(s) said Thank You: krileon

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

  • XBOOMX
  • XBOOMX
  • OFFLINE
  • Posts: 131
  • Thanks: 12
  • Karma: 0
5 years 2 months ago #314740 by XBOOMX
Replied by XBOOMX on topic Userlist, only show users who are online.
( SELECT COUNT(*) FROM `#__session` AS s WHERE s.`userid` = u.`id` AND s.`guest` = 0 ) > 0 AND ue.`cb_gender` = 'm'

This way only the male users are shown. That would be correct, if I log in as a female user.
I need it separately. Female logged in only see male logged in. And around, of course, too.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48616
  • Thanks: 8302
  • Karma: 1446
5 years 2 months ago #314748 by krileon
Replied by krileon on topic Userlist, only show users who are online.
You only want it to show males if a female is logged in and only females of a male is logged in? If that's correct the below would do that.

Code:
( SELECT COUNT(*) FROM `#__session` AS s WHERE s.`userid` = u.`id` AND s.`guest` = 0 ) > 0 AND ue.`cb_gender` = '[cb:if cb_gender="m"]f[cb:else]m[/cb:else][/cb:if]'


The IF substitution checks against the user viewing the userlist. If they're male it will filter the list to those who have female selected as the gender otherwise it will show users who have male selected as the gender.


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: XBOOMX

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

  • XBOOMX
  • XBOOMX
  • OFFLINE
  • Posts: 131
  • Thanks: 12
  • Karma: 0
5 years 2 months ago #314752 by XBOOMX
Replied by XBOOMX on topic Userlist, only show users who are online.
Thanks krileon, that's the way it should be. Got it tested, works perfect.
The following user(s) said Thank You: krileon

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

  • XBOOMX
  • XBOOMX
  • OFFLINE
  • Posts: 131
  • Thanks: 12
  • Karma: 0
5 years 2 months ago #314755 by XBOOMX
Replied by XBOOMX on topic Userlist, only show users who are online.
Can I extend this post by a similar one?
I also have a menu item "New Members". I would now create a new user list that displays new members, following the same principle as in the top posts. This time all new members should be displayed. The Community Builder Online module is good, but does not provide the configuration like a user list.
How does the database query look like to display new users, let's say for a month? After one month, they are not new and should therefore no longer be displayed as new.

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

Moderators: beatnantkrileon
Powered by Kunena Forum