I am trying to implement the Login/Member Profile update page and have not been successful in getting it to work properly. While the Login button DOES validate the member, change to Logout along with displaying the My Profile button, Clicking on My Profile does NOTHING?
Facts:
- I have a custom database called CVOA_Members that gets initially populated by a static User Input Form. This is working properly. When I select Manage Dataset it shows:
- I implemented the Member Profile pages following the article:
https://support.wix.com/en/article/how-to-create-member-profile-pages-with-wix-code
In doing so I duplicated my original page containing the User Input form an then made it a Dynamic Page for use with this article when the user clicks on My Profile after logging in.
What is confusing is that if I select this new dynamic page and click on Manage Dataset it shows:
NOTICE the two different Dataset Names? Is this possibly why I cannot get the Member Profile button to do anything?
- Here is my Wix Code for the Membership Profile that is shown behind the Dynamic page update form, as described in the article:
import wixUsers from ‘wix-users’;
import wixData from ‘wix-data’;
import wixLocation from ‘wix-location’;
$w.onReady( () => {
if(wixUsers.currentUser.loggedIn) {
$w(“#button2”).label = “Logout”;
$w(“#button3”).show();
}
else {
$w(“#button2”).label = “Login”;
$w(“#button3”).hide();
}
} );
export function button2_click() {
// user is logged in
if(wixUsers.currentUser.loggedIn) {
// log the user out
wixUsers.logout()
.then( () => {
// update buttons accordingly
$w(“#button2”).label = “Login”;
$w(“#button3”).hide();
} );
}
// user is logged out
else {
let userId;
let userEmail;
// prompt the user to log in
wixUsers.promptLogin( {"mode": "login"} )
.then( (user) => {
userId = user.id;
return user.getEmail();
} )
.then( (email) => {
// check if there is an item for the user in the collection
userEmail = email;
return wixData.query("CVOA_members")
.eq("_id", userId)
.find();
} )
.then( (results) => {
// if an item for the user is not found
if (results.items.length === 0) {
// create an item
const toInsert = {
"_id": userId,
"email": userEmail
};
// add the item to the collection
wixData.insert("CVOA_members", toInsert)
.catch( (err) => {
console.log(err);
} );
}
// update buttons accordingly
$w("#button2").label = "Logout";
$w("#button3").show();
} )
.catch( (err) => {
console.log(err);
} );
}
}
export function button3_onclick() {
wixLocation.to(/CVOA-MemberProfile/${wixUsers.currentUser.id}
);
}
- If I select My Profile buttton in the header note that onClick name matches wix code
- Here is the info for the Dynamic Page that should be invoked by the My Profile button and the URL matches the last line of the Wix Code.
Can someone PLEASE tell me what I am missing. I have been fighting with this for over two weeks, multiple other posts, comments, upgraded to Premium plan to get VIP support then logged a support ticket and was told Wix Support does not handle wix code. Two days ago when Wix Code was release I tried again and was told that I must use this forum to get assistance.