Hi all, My button won’t redirect to the location in my account section.
I have been trying for the past 24 hours and I just can’t find a way. I am not sure if the button is functioning at all. If you want to take a look its www.inshapeithcraig.co.uk
upon login go to profile and the button will be there, “createProfileButton”
please help its driving me crazy.
thank you, code is posted below. one for profile page and other for sign in page.
this is the code i have for the my profile page (I followed a video)
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);
});
});
this is the code 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(“#createProfileButton”).onClick( () => {
let toInsert = {
“firstName”: $w(“#firstName”).value,
“lastName”: $w(“#lastName”).value,
“emailAddress”: $w(“#emailText”).value,
};
wixData.insert(“Members”, toInsert)
.then( () => {
wixLocation.to("/account/my-profile");
} )
. catch ( (err) => {
let errorMsg = err;
$w("#error").show();
} );
});
});