I have a custom member's page where I would like to print the user's first name in a string. For example, let's say the user is called Bob. I would like to print a string which says 'Hi, Bob!'.
This is my code which I have wrote currently to print the user's ID. How can I update this code to print the user's name instead?
import wixUsers from 'wix-users'; let name = wixUsers.currentUser.id; $w.onReady(function () { if(wixUsers.currentUser.loggedIn) { $w('#text293').text = 'Hi,' + name + '!'; } });
You should get the name from the database and only then you'll be able to display it.
$w.onReady(() => { currentMember.getMember(fieldsets: [ 'FULL' ]) .then(member => $w('#text293').text = `Hi, ${member.contactDetails.firstName}!`); })