Hey can anyone help me with this one?
https://codequeen.wixsite.com/membership-dashboard
https://www.youtube.com/watch?v=yLCOqsVHhD0
I successfully have it working, but I'm wandering if there is anyway to make the referral code there first and last initials and the last four of there phone number?
here's the codes:
for the Profile Page
import wixData from 'wix-data';
$w.onReady(function () {
$w("#updateProfile").onReady( () => {
let isEmpty = $w("#updateProfile").getCurrentItem();
let theName = $w("#firstName").value;
if ( isEmpty === null ) {
$w("#createProfileButton").show();
$w("#updateProfileButton").hide();
$w("#profileArea").collapse();
$w("#welcomeUser").text = `Welcome New User. Please create a profile!`;
} else {
$w("#updateProfileButton").show();
$w("#welcomeUser").text = `Welcome ${theName}`;
$w("#profileArea").expand();
}
} );
$w("#updateProfile").onAfterSave( () => {
let theName = $w("#firstName").value;
$w("#welcomeUser").text = "Update Completed!";
const millisecondsToDelay = 2500;
setTimeout(() => {
$w("#welcomeUser").text = `Welcome ${theName}`;
}, millisecondsToDelay);
});
});
for the Sign Up Page
import wixUsers from 'wix-users';
import wixData from 'wix-data';
import wixLocation from 'wix-location';
$w.onReady(function () {
let user = wixUsers.currentUser;
let userId = user.id; // "r5cme-6fem-485j-djre-4844c49"
let isLoggedIn = user.loggedIn; // true
user.getEmail()
.then( (email) => {
let userEmail = email;
$w("#emailText").value = userEmail;
let referralCode = userId.split("-")[4];
$w("#referralCode").text = referralCode;
} );
$w("#createProfileButton").onClick( () => {
let toInsert = {
"firstName": $w("#firstName").value,
"lastName": $w("#lastName").value,
"emailAddress": $w("#emailText").value,
"phone": $w("#phone").value,
"username": $w("#username").value,
"referredBy": $w("#referredBy").value,
"referralCode": $w("#referralCode").text
};
wixData.insert("profile", toInsert)
.then( () => {
wixLocation.to("/account/profile-page");
} )
.catch( (err) => {
let errorMsg = err;
$w("#error").show();
} );
});
});
@Code Queen Nayeli
That wonderful tutorial is supplied by Wix Expert Nayeli (Code Queen) and not Wix itself.
https://codequeen.wixsite.com/membership-dashboard
I would strongly suggest that you contact her yourself first if you have any questions about it.
https://www.mycodequeen.com