I have a members only page that requires login. Is it possible with wix code to grab the email address from the current user and place in a form field?
Hi Eddie,
Yes, it is possible to grab a member’s email using code.
You can see the relevant call and example here
Additionally, we also have a step-by-step article for creating member profile pages in Wix Code, which you can see here
Hi there. Not sure if the first link above is meant to be something else but I’m also trying to do this. I’ve got a members only form connected to a database. I’ve got a field (#input4) which I would like to auto populate with the logged in users email. I can’t find a code snippet anywhere. (Confession: Not a web developer, a dabbler at best Thanks in advance.
Hi Owen,
Try this:
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('#input').value = userEmail;
}
);
Thank you Will give it a try!!
@owenjoyce2015 did you get this to work?
As part of one of my questions on another post, I’m also trying to do this. Here is my post (if you could take a look, Jeff):
Thanks in advance.
This did not work when I tried it. I’m not a developer either and am not sure which “event” to attach this code to in order to get the email to appear on their submitted response when I review form submissions. No, I do not want to add the email field to the form and have my client type in their email address every time they hit the submit button. They are already logged in on my site, I shouldn’t need to ask for their email every time they submit the form to me.
Hi, I have an event page that is open to all for registration where we have a form but I want the members to save the pain of filling the form again and so is there a way we can populate the form details for the members from the table?
I could do the email part from some codes available here but not the name and phone number part.
@tony-brunsman can you please help