if (isLoggedIn) {
wixData.query("Members/PrivateMembersData")
.eq("_id", wixUsers.currentUser.id)
.find()
.then((results) => {
//This changes the text to for example Hi Sivan:
$w("#yourText").text = "Hi " + results.items[0].firstName;
//Put any script using the variable here
})
}
With this code you can let a text box (yourText) say Hi Sivan (or the current user’s name). You can also change button labels, but then you have to change .text to .label.
Hope this helps!
if (isLoggedIn) {
wixData.query("Members/PrivateMembersData")
.eq("_id", wixUsers.currentUser.id)
.find()
.then((results) => {
//This changes the text to for example Hi Sivan:
$w("#yourText").text = "Hi " + results.items[0].firstName;
//Put any script using the variable here
})
}
Hi does this code still work bud? it only seems to work for me in preview mode, would this be something to do with the permissions of the Members/PrivateMemberData? to only allow admin to view it? thanks
The code suggested by Quinten has worked in the past (just 2 or 3 weeks ago), but as Stevo suggests, it isn’t working today. It now throws an error (error text below). I don’t know precisely when it began to fail. Can someone confirm whether this is an anomaly or if it’s the new “expected/correct” behavior?
This is the error I get (whether called as admin or non-admin user:
Error: {“message”:“missing_context, details: {"fields":"MSID / (appDefId, instanceId)","apps":"null","entities":"{\"context\":{\"appDefId\":\"eb377299-86b4-4a86-a1b5-774a2d1d374b\"},\"identities\":[{\"service\":{\"appDefId\":\"eb377299-86b4-4a86-a1b5-774a2d1d374b\"}}]}"}”,“details”:{“entities”:“{"context":{"appDefId":"eb377299-86b4-4a86-a1b5-774a2d1d374b"},"identities":[{"service":{"appDefId":"eb377299-86b4-4a86-a1b5-774a2d1d374b"}}]}”,“error”:“missing_context”,“fields”:“MSID / (appDefId, instanceId)”,“category”:“api_error”,“apps”:“null”}}
If you simply want to show the site members first name on their dynamic page for example, then just have a simple text box element linked to first name field in the Wix Members app collection.
As it will be only that site member who has access to that dynamic page, then it will simply just show the first name of that logged in user.