I used this code to retrieve the information of a member from a custom dataset but instead it is returning the same data in all member account. My intent is to return only the member data log in.
Need help please
import wixUsers from ‘wix-users’;
import wixdata from ‘wix-data’
$w.onReady( function () {
wixUsers.onLogin((user) => { let userId = user.id; // “r5cme-6fem-485j-djre-4844c49” let isLoggedIn = user.loggedIn; // true if (wixUsers.currentUser.loggedIn) {
user.getEmail()
.then((email) => { let userEmail = email; // “user@something.com”
$w(“#MemberPlanDataset”).onReady(() =>
user.getMemberPlanDataset()
.then((MemberPlanDataset) => { let UserPlan = MemberPlanDataset; let Myemail = UserPlan.email; if ((userEmail) === UserPlan.email) { let MyPlan = UserPlan.Plan; let MyPrix = UserPlan.Prix; let MyStatut = UserPlan.Statut; let MyValidite = UserPlan.validite;
} else {
$w(“#box18”).show();
Thanks for the feedback, I used query to get the results but it still doesn’t give the infos of the member logged in.
below is the code, can you check it please? Thanks
import wixData from ‘wix-data’; import wixLocation from ‘wix-location’;
export function getUserDataByEmail(email) {
$w.onReady( function () {
wixData.query(“MemberPlanDataset”)
.eq(“loginEmail”, email)
.then((results) => { let Myemail = email; if (wixUsers.currentUsers.email === Myemail) {
wixUsers.getMemberPlanDataset()
.then((MemberPlanDataset) => { let UserPlan = MemberPlanDataset; let MyPlan = UserPlan.Plan; let MyPrix = UserPlan.Prix; let MyStatut = UserPlan.Statut; let MyValidite = UserPlan.validite;
})