Hello, i have already created a user interface and login functions (https://www.wix.com/code/home/forum/questions-answers/members-profile)
I want to modify the code a bit -
I want when the client clicks the Login button to be redirected to the Login/Signup Page, but after that to check the database if the user.email of the login exists.If it does exist, redirect them to /Clients/ + Email , otherwise use the wixlocation to redirect to the signupform lightbox.
i tried to do the check if email exists using
wixData.query("Client_List")
.eq("email", userEmail)
.find() .then((results) => {
let firstItem = results.items[0];
var exist = firstItem.email;
and then if exist === userEmail redirect…
But i get this error.
Yep, you’re on the right track now. You basically want to check to see if any results are returned.
So, something like:
wixData.query("Client_List")
.eq("email", userEmail)
.find()
.then((results) => {
if(results.items.length > 0) {
// we found at least one match
// ...
}
}
This is similar to what we show in a new article that was just published:
Hi, I have a problem that is pretty similar to the one above.
I have a site that sells paid language lessons.
Im trying to set that when a user clicks on a lesson Image there a query that checks if the user email exists in the paid member collection. if it does exist he needs to be redirected to the lesson page, if not theres a lightbox that says he needs to pay first.
There seems to be no problems with my code, but still it doesn’t work
Im inserting few email addresses to the paid member collection,just for example, and then trying to login with one of them as a site member. But even that the email Im using do exists in the live collection Im not being redirected to the lesson and I get only the lightbox says I need to pay.