Make input field drawn from logged in user profile pass to the CMS collection

I use Wix Editor, Dev mode. I have added the below code to an input field on a form which only logged in members can get to. It very nicely puts the email address into the email input field on the form, however, after the user submits the form, the email address does not populate the email field in the collection. Also, which bits do I edit in the code so that it will also insert the name? My collection has a text field of Name and the form has an input field called Name.

// Velo API Reference: Velo Docs
// Velo API Reference: Velo Docs

import wixUsers from ‘wix-users’;
// …
let user = wixUsers.currentUser;
let userId = user.id;
let isLoggedIn = user.loggedIn;
let userRole = user.role;
let username = user.name
user.getEmail()
.then( (email) => {
let userEmail = email; // “user@something.com
$w(‘#input11’).value = userEmail;
}
);

Thank you

if you code anything in a form, then you need to code all the inputs to save to the CMS.

also please use the preformatted text when adding code.
like this

import wixUsers from ‘wix-users’;
// …
let user = wixUsers.currentUser;
let userId = user.id;
let isLoggedIn = user.loggedIn;
let userRole = user.role;
let username = user.name
user.getEmail()
.then( (email) => {
let userEmail = email; // “user@something.com”
$w(‘#input11’).value = userEmail;
}
);
1 Like

Dan, I want to avoid custom forms and stick with the standard wix form. I want to validate that the email address entered is the same as the logged in value. Can I write validation code in the email field in a standard form? Thanks