Help with undefined values.

Hi Folks, Anyone know why I’m getting an ID but all my other fields are undefined? I’ve commented out the insert for now so I’m just going by the console logs. Name, loginemail and mainPhone are all undefined.

import wixUsers from ‘wix-users’ ;
let user = wixUsers.currentUser;
let userId =;
let name =;
let loginEmail = user.loginEmail;
let mainPhone = user.mainPhone;

$w.onReady( function () {
$w( “#learnerData” ).onReady(() => {

    wixData.query( "Learners" ) 
        .eq( "_id" , userId) 
        .then((results) => { 

if (results.items.length > 0 ) {
} else {
// wixData.insert(‘Learners’, { userId, name, loginEmail, mainPhone });
. catch ((err) => {
let errorMsg = err;


To get user email, you need to use getEmail function.

As for the name, you need to query Members/PrivateMembersData collection with user ID and get the names as shown in sample code below:

        .then((results) => {

Please note that these code should be inside the if but not else statement.

As for the phone number, this is not a built-in field in the Members/PrivateMembersData collection.

Assuming you have such a field in the learners’ collection You will have to access it using:


Good luck!

thanks for the help!