Using register to add data to PrivateMembersData

Hello! I read on this forum that someone suggested looping through data with register() from a second database to auto-populate PrivateMembersData since we can’t add data directly here. I’m designing a website for my fitness studio and we want to avoid manually inputting all customer data when we switch booking systems.

I’m pretty new to JavaScript but I compiled this from several resources. Any idea why the register() part isn’t properly pulling from my database and filling PrivateMembersData? It initiates when you click a trigger button.

// For full API documentation, including code examples, visit Velo API Reference - Wix.com
// import APIs
import wixUsers from ‘wix-users’ ;
import wixData from ‘wix-data’ ;

$w.onReady( function () {
$w( ‘#button5’ ).onClick( () => {

// create for loop to run thru all items in database
wixData.getItems( 0 , ( “MB_Data” ).getTotalCount())
.then((result) => {
var allItems = result;
for ( let i = 0 ; i < result.count ; i++) {

// assign database to email variable
wixData.get( “MB_Data” , { “fieldKey” : “emailAddress” })
.then( (resultsA) => {
// might need to define variable differently
var email = resultsA;
} )

// assign database to password variable
wixData.get( “MB_Data” , { “fieldKey” : “password” })
.then( (resultsB) => {
// might need to define variable differently
var password = resultsB;
} )

// assign database to firstName variable
wixData.get( “MB_Data” , { “fieldKey” : “firstName” })
.then( (resultsC) => {
// might need to define variable differently
var firstName = resultsC;
} )

// assign database to lastName variable
wixData.get( “MB_Data” , { “fieldKey” : “lastName” })
.then( (resultsD) => {
// might need to define variable differently
var lastName = resultsD;
} )

// assign database to phone variable
wixData.get( “MB_Data” , { “fieldKey” : “phoneNumber” })
.then( (resultsE) => {
// might need to define variable differently
var phoneNumber = resultsE;
} )

            wixUsers.register(email, password, { 
                    contactInfo: { 

“firstName” : firstName,
“lastName” : lastName,
“phoneNumber” : phoneNumber,
“label” : “Not New Member”
}
} )
.then( (value) => {
let resultStatus = value.status;
} )
}
});
});
});

Oh boy, that´s a lot of get´s that you do. How about doing a query only once, and then do the for-loop, retrieve all fields per row in 1 go and with that, create the user. Also wix.data get() only works with an _id, which you don´t have.