Hi! Is it possible to somehow have a databse (w/dataset) that is connect to the Wix Member Login?
Hi Jason!
At this point it’s not possible to integrate any of WixCode features with verticals (WixStores, WixBookings or so). Same for members.
It will be developed (for sure) but i can’t give you any estimations “when”.
But, there is a solution for members database - you can create and maintain this process by code, with this article:
Thank you so I miss much! The article is very informative and guiding! I I’ll try to set this up ASAP!
Hello,
I just finished and it worked perfectly! Yet, I have one more question…the collection created had other fields, so can I ONLY WHEN AN ACCOUNT IS REGISTERED (entry added to collection) that it redirects user to possibly this:
wixLocation.to(`/Users/Update/${wixUsers.currentUser.id}`);
in order for them to finish setting up their profile (such as name, phone, etc.)?
I know that’s where the wixLocation would need to lead to but I don’t know where I would put this into my code and how to ensure this is only done when a new entry (account creation) occurs? Any assistance would be great and very much appreciated!
Best regards,
Jason LaPierre
P.S. Here is my complete existing code:
// For full API documentation, including code examples, visit http://wix.to/94BuAAs
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("#profileButton").show();
}
else {
$w("#loginButton").label = "Login";
$w("#profileButton").hide();
}
} );
export function loginButton_click(event, $w) {
// user is logged in
if(wixUsers.currentUser.loggedIn) {
// log the user out
wixUsers.logout()
.then( () => {
// update buttons accordingly
$w("#loginButton").label = "Login";
$w("#profileButton").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("Users")
.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("Users", toInsert)
.catch( (err) => {
console.log(err);
} );
}
// update buttons accordingly
$w("#loginButton").label = "Logout";
$w("#profileButton").show();
} )
.catch( (err) => {
console.log(err);
} );
}
}
export function profileButton_click(event, $w) {
wixLocation.to(`/Users/${wixUsers.currentUser.id}`);
}
As mentioned above, to be able to get to each database for an App would be nice.
My question following may be premature as I have not had time to test it myself but will ask:
Q: Are all the App databases integrated?
In addition to my previous question as well…what happens to previously existing users? Is there any way to have them added?
@Robert, answering this Q: Are all the App databases integrated?
No, at this point there is no integration with existing apps
This is for sure very important and we know it) it will be developed, but i can’t give you any estimations
Simple answer - looks like you need to add it here: 2017-12-20_1542
To the section if (results.items.length === 0) { … [here at the end] }
Long answer - this section happens when query doesn’t find existing user with such email
So i advise you to try to understand how this logic works - it’s simple "if"s, which happen with different scenarios
Sounds good thank you! I’ve modified my code personally a bit from the very minimum knowledge I have.
I have one more question relating to this, yet I don’t think it requires code. What happens to the old already existing users? How can they get their profile as well since they are technically not in the database as entries are only added after a successful signup.
Foir now - only way to add them is to ask them sign up again
Due to the fact that you don’t have access to their passwords in our collection - only log-ins, eg emails
Hello,
Seeing as their email is already registered it won’t let them signup again as their email has already been used. Would I just remove them from the Wix Contacts in my Wix dashboard or must I follow some other step to ensure they can get their profile?
So many thanks for your help thus far.
Regards,
Jason
Would I just remove them from the Wix Contacts - unfortunatrly, this one so far. As i said - no existing integration anywhere, we didn’t develop yet mechanizms to supply this processes automatically
Hello everyone. I’m new to wix code and i have below issue. Please guide me!!!.
I am building a parking website with login page. When a certain user is logged in he can click a button and navigate to parking zone.
now this is the first page when a user will log in to the website. when the user clicks on parking zone button , user will be redirected to second page as shown below.
Here all the boxes in red are container boxes. when the user clicks on any red box say 31, it should turn into green and should be updated automatically. So if when another user log in and navigate to second page , he should see the box 31 in green color.
To explain my requirement in better way, only 30 users will use this website . i have to assign all 30 users with a container box in red color by default. if any user clicks on his assigned box it should turn into green and this change in color should be updated globally so that all the other 29 users can see that change has been made by some user.
So, please help me if this requirement is possible.
Hi,
Please re-post your question in a new thread.
Thanks,
Tal.