I need to get the current loggedIn users and show the count, also when click on button it should open a popup and show the names of current loggedIn users.
I can get the total user but don’t know, how to get logged in users
Thanks for the help
I need to get the current loggedIn users and show the count, also when click on button it should open a popup and show the names of current loggedIn users.
I can get the total user but don’t know, how to get logged in users
Thanks for the help
Hello little engineer ,
take a look on these examples here at my helping site…
https://russian-dima.wixsite.com/meinewebsite/user-infos
You can modify this code-snipet here…
import wixUsers from 'wix-users';
// ...
wixUsers.onLogin( (user) => {
let userId = user.id; // "r5cme-6fem-485j-djre-4844c49"
let isLoggedIn = user.loggedIn; // true
let userRole = user.role; // "Member"
} );
…and start your own created function, which will do for example an entry into a database, telling that this current logged in user is ONLINE just right now.
So every USER who loggs in, will be collected in your DATABASE (for example boolean-value → ONLINE = TRUE/FALSE).
where should I right this function, user can login in any page so where can I handle onLogin?
How can I find user logs out when his session is expired?
Try add this to your code
if (wixUsers.currentUser.loggedIn === true) {