Pretty sure a tried and true code. Had been working, but now not working.
It is intermittent on pulling info into user input…half the time have to refresh page to get it to pull up, but then it is not actually putting info into the field on submit (was previously working fine).
import wixUsers from ‘wix-users’;
// …
let user = wixUsers.currentUser;
let userId = user.id;
let isLoggedIn = user.loggedIn;
let userRole = user.role;
user.getEmail()
.then( (email) => {
let userEmail = email; // “user@something.com”
$w(“#input23”).value = userEmail;
}
);
Make sure the code is in the onReady function.
@brettfranklin2 that perhaps was an issue, but not sure why it worked for a time (unless I had originally in there and then removed (I have had some mysterious issues with changes being made to my site).
But have implemented onReady and still not working…
import wixUsers from ‘wix-users’;
$w.onReady( function () {
let user = wixUsers.currentUser;
let userId = user.id;
let isLoggedIn = user.loggedIn;
let userRole = user.role;
user.getEmail()
.then((email) => {
let userEmail = email; // “user@something.com”
$w(“#input4”).value = userEmail
})
});
seems to be consistantly pulling the email into the user input box, but just not getting to the database as before.
Did you ever find a way to fix this? I am having the same issue using input fields. Seems to work fine when I use a wix form.
Fix what? What is your problem? This is an old post you are commenting on. Please repost your question in a new post so more people will see it. Clearly explain what you are trying to do and what you want to accomplish.
The thread is being closed.