I created a custom log in page using this link Velo Tutorial: Building Your Own Members Area | Help Center | Wix.com
This line of code bellow returns a user id that is different than the ID’s in my data set. As we know, ID’s are locked in data sets, so it can’t be changed (at least I can’t/haven’t). Additionally, it consistently returns the same incorrect ID based on which ever test account I attempt to use. What is going on? (dmList is the name of my dataset)
wixLocation.to(/dmList/${wixUsers.currentUser.id}
);
after doing some snooping around I found one of the links goes being used for currentUser.id is actually the Owner number. Still doesn’t help me too much as I can’t use the owner number as a field to direct to my dynamic user page
#dataset #query #customloginpage #wixUsers #wixcode #customprofile #dynamicpage
The (user) ID field that is used is in all your datasets, it is just set as hidden when you create a dataset, if you want to see it then you need to make it visible in your dataset.
ID (_id)
Description : The member ID that was created by the server. This is a system field and is hidden by default.
Type : Text
Can connect to data : Yes
Can use in dynamic page URL : Yes
Read-only : Yes
Plus whatever ID Wix gives a user, it should stay the same throughout the datasets and not change.
I’ve just checked my two datasets of mine, my Members dataset which I use for my own Members Profile page and my PrivateMembersData dataset and all the ID fields have the same ID for myself.
PrivateMembersData: My ID - XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
Members:
ID: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
Members ID: /Members/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
Members Update ID: /Members/Update/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
As you can see from the tutorial the export function takes you to the users own member profile page
export function profileButton_click(event) {
wixLocation.to(`/Members/${wixUsers.currentUser.id}`); }
If you wanted the user to go straight to their user member profile update page then it would be
export function profileButton_click(event) {
wixLocation.to(`/Members/Update/${wixUsers.currentUser.id}`); }
i used that code myself and changed it for my own members page and everything works fine.
// For full API documentation, including code examples, visit http://wix.to/94BuAAs
$w.onReady(function () {
//TODO: write your page related code here...
});
import wixUsers from 'wix-users';
import wixData from 'wix-data';
import wixLocation from 'wix-location';
$w.onReady( () => {
if(wixUsers.currentUser.loggedIn) {
$w("#loginbutton").label = "Logout";
$w("#membersareaonlystrip").expand();
$w("#whitegapforfooter").hide();
}
else {
$w("#loginbutton").label = "Login";
$w("#membersareaonlystrip").collapse();
$w("#whitegapforfooter ").show();
}
} );
export function loginbutton_onclick(event) {
// user is logged in
if(wixUsers.currentUser.loggedIn) {
// log the user out
wixUsers.logout()
.then( () => {
// update buttons accordingly
$w("#loginbutton").label = "Login";
$w("#membersareaonlystrip").collapse();
$w("#whitegapforfooter ").show();
} );
}
// user is logged out
else {
let userId;
let userEmail;
// prompt the user to log in
wixUsers.promptLogin( {"mode": "signup"} )
.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("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("Members", toInsert)
.catch( (err) => {
console.log(err);
} );
}
// update buttons accordingly
$w("#loginbutton").label = "Logout";
$w("#membersareaonlystrip").expand();
$w("#whitegapforfooter").hide();
} )
.catch( (err) => {
console.log(err);
} );
}
}
export function profilebutton_onclick(event) {
wixLocation.to(`/Members/${wixUsers.currentUser.id}`);
}
export function entermembersbutton_onclick(event) {
wixLocation.to(`/members-area`);
}
export function myaccountbutton_onclick(event) {
wixLocation.to(`/account/my-account`);
}
export function websiteupdatebutton_onclick(event) {
wixLocation.to(`/website-update`);
}
Plus if you want to use that as a custom login page, then you are better off doing what I have done with the page and adding a custom login lightbox to it too.
As currently, just using that code will log members in, however the page code won’t work as it needs to be refreshed for it to kick in and work.
Just simply create a custom login lightbox and change your member signup settings to custom and use this code on your lightbox.
import wixUsers from 'wix-users';
import wixLocation from 'wix-location';
import wixWindow from 'wix-window';
$w.onReady(function () {
$w("#forgotPassword").onClick( (event) => {
//wixWindow.lightbox.close()
wixUsers.promptForgotPassword()
.then( ( ) => {
//
} )
.catch( (err) => {
let errorMsg = err; //"The user closed the forgot password dialog"
});
});
});
export function loginButton_onclick(event) {
let email = $w("#email").value;
let password = $w("#password").value;
wixUsers.login(email, password)
.then( () => {
console.log("User is logged in");
wixWindow.lightbox.close();
wixLocation.to(wixLocation.url); //This reloads the same page and allows code to show hidden member parts.
} )
.catch( (err) => {
console.log(err);
$w("#errorMessage").expand(); // You can delete this line if you are not going to add an error message. Use a regular text element set to 'collapse on load' from the Properties Panel.
} );
}
I don’t think you understand. I am using wixUsers.currentUser.id and instead of going to the www.websitename/databasename/ID it is going to www.websitename/databasename/Owner.
Owner can not be used so my website continual goes to page not found. I have no idea how to fix this because people keep telling me it should work
Have you already solved it Andreas Graham? 'Cause I’m also having this issue. I don’t know what code should be added in my existing code. 

…
I wanted to know the code wherein after a person sign up, I could get his/her ID in PrivateMembersData , and insert it in my own database specifically in “_id”
Andreas Graham, have you already solved it? ’ Cause we have the same problem. I haven’t solved it yet till now… 


I wanted to know the code wherein after the person sign up, the ID in PrivateMembersData will be inserted in another Database specifically in “_id” so that the code below will work.
export function profileButton_click(event) {
wixLocation.to(`/Members/${wixUsers.currentUser.id}`); }
Because if I will not have additional code in my existing code, then the ${wixUsers.currentUser.id} will be the ID in PrivateMembersData not the ID in my own Database.
@aeroengineerz7 Hi Juan, To get the best support for your issue, please create a new post with a detailed description, code, and any other relevant information. Posting guidelines are here . Thanks!