@cryptoirt
Ok, just did a test on my own LOGIN and registered a new “Test-User” → èt-voila! → The user was logged-in → automaticaly…
I will now take a look onto my CODE, to refresh my BRAIN again 
Looking onto my own console-logs…

I am able to get a USER-ID directly after the registration-process → That means you should also be able to do the same
…
Stay-tuned, i take a look to find the right part of code…
@russian-dima Ohhh pleasee! I have been with this ID issue for days!
@cryptoirt
Ok…an excerpt of my Regi… (in simple form)…
//....
wixUsers.register(email, password,{
contactInfo: {
"firstName": "firstname",
"lastName": "lastname",
}
})
.then(async(result)=>{console.log("Update-Contact running...")
let userStatus = await result.status; console.log("User-Status: ", userStatus)
let userID = await result.user.id; console.log("User-ID: ", userID)
})
Inspect the → result
Take also a look at —> console.log(“Update-Contact running…”)
Find this console.log in the shown console.log of the following pic…

Followed by —>
- let userStatus = await result.status; console.log("User-Status: ", userStatus)
- let userID = await result.user.id; console.log("User-ID: ", userID)
@russian-dima i tried your code and now is giving me this new error message
Code:
if(($w('#password').value===($w('#confirmPassword').value))){
doRegistration(email, password, firstName, lastName)
.then(async(result)=>{console. log("Update-Contact running...")
let userStatus = await result. status; console. log("User-Status: ", userStatus)
let userID = await result.user. id; console. log("User-ID: ", userID)
const toInsert = {
"_id": userID,
"email": email,
"nombre": firstName,
"apellido": lastName,
}
wixData. insert("Members", toInsert)
})
}
@cryptoirt
Hmmmm, the only big difference which i can see between my and your version, is that you are doing it on backend and me on frontend.
Anyway, it’S time to use the → BACKDOOR… try this one…
wixUsers.onLogin(async(user) => {
try{//show Login-setup....
userID = await user.id; console.log("User-ID: ", userID);
isLoggedIn = await user.loggedIn; console.log("User-Logged-In: ", isLoggedIn);
start_OnLoginProcess();
}catch{console.log("ERROR --> onLog-In-process!")}
});
function start_OnLoginProcess(){
//your on-Log-in-function here.....
}
You can add this in the onReady-Section of your code.
Check also this part of code in your BACKEND… change it to …
import wixUsers from 'wix-users-backend';
export function doRegistration(email, password, firstName, lastName) {
// register the user
return wixUsers.register(email, password, {
"contactInfo": {
"firstName": firstName,
"lastName": lastName
}
})
.then(async(results)=> {
await wixUsers.emailUser('verifyRegistration', results.user.id, {variables:
{approvalToken: results.approvalToken}})
return results
});
}
Try it out.
Deactivate some functions first in your code, to debug your code better and faster.
This should be the most interesting part where to search for the bug…
(In your case —> BACKEND )
export function doRegistration(email, password, firstName, lastName) {
// register the user
return wixUsers.register(email, password, {
"contactInfo": {
"firstName": firstName,
"lastName": lastName
}
})
.then((results)=> {return results
//await wixUsers.emailUser('verifyRegistration', results.user.id, {variables:
//{approvalToken: results.approvalToken}})
});
}
Which RESULTS do you get ??? —> (return results)
You get this results directly after REGISTRATION, sending them back to FRONTEND.
FRONTEND-CODE: (another attempt using async-await)
$w.onReady(function(){
$w('#RegButton').onClick(async function (){
let firstName = $w("#nombre").value
let lastName = $w("#apellido").value
let email = $w("#email").value
let password = $w("#password").value
let confirmPassword = $w("#confirmPassword").value
if ($w('#password').value === $w('#confirmPassword').value) {
let RESULTS = await doRegistration(email, password, firstName, lastName)
console.log("RESULTS: ", RESULTS)
//let user = wixUsers.currentUser; console.log(user)
//let userId = user.id; console.log("User-ID: ", userId)
}
else { /* ... */ }
});
});
What do you get in CONSOLE for RESULTS ?
@russian-dima I will check now the others codes that you sent me.
@cryptoirt Check my last suggestion first… (Async-Await-version)
Interesting —> Which RESULTS do you get after register a new user ?
@russian-dima
This code says that a async function is missing.

@cryptoirt
Pay attention when copy and paste!
$w('#RegButton').onClick(async function(){

@cryptoirt
Please → OPEN the → 3-dots & show the results.
@cryptoirt
It’s another ID than on the beginning of your post. 
And i think i got it.
The STATUS of the registered user is → “PENDING”
In my case i do not use → approval-system and the user gets logen-in directly after registration.
In your case it seems to be different.
@russian-dima Yessss! let me check in the database if all is going well!
@cryptoirt Well! I showed you, how to debug own code → by using some more of → CONSOLE-LOGs.
REMEMBER!!! —> Console.log → is your BEST-FRIEND !
Now, i will leave you. You are very close to solve it! And i am sure, you will be able to solve the rest by your own.
Let me know, when you got your SOLUTION!
And do not forget to like it, if you really liked it
.
Time to go to bed! Over and out!
@russian-dima Uff i will try! For now the verification is not being sent, the login is not working and the ID is not being insert into the database. But i think that with some little changes can work. Let´s see. Tomorrow i will send you the results xD.
Thanks for all!
@cryptoirt
Nothing is working, because you deactivated or cut it off here…
$w.onReady(function(){
$w('#RegButton').onClick(async function (){
let firstName = $w("#nombre").value
let lastName = $w("#apellido").value
let email = $w("#email").value
let password = $w("#password").value
let confirmPassword = $w("#confirmPassword").value
if ($w('#password').value === $w('#confirmPassword').value) {
let RESULTS = await doRegistration(email, password, firstName, lastName)
console.log("RESULTS: ", RESULTS)
//let user = wixUsers.currentUser; console.log(user)
//let userId = user.id; console.log("User-ID: ", userId)
}
else { /* ... */ }
});
});
You will have to reactivate every function back.
And of course you now can change the following lines, too…(using the RESULTS)
//let user = wixUsers.currentUser; console.log(user)
//let userId = user.id; console.log("User-ID: ", userId)
let userID = RESULTS.user.id; console.log("User-ID: ", userID)