Check if data exist in Db

Hi,
I have a form that I created that populates a Database called ListeMembres.

I would like to code something that will check if a record exists for the email entered at Login/Signup. Following the result of this check, I want to Hide or Show a textbox.

Thank for your help

Pierre Lacasse

1 Like

Hey

  1. Get logged in user
    http://www.wix.com/code/reference/wix-users.html#currentUser

  2. Query data collection
    http://www.wix.com/code/reference/wix-data.html#query

  3. Hide / Show Box
    http://www.wix.com/code/reference/$w.Box.html#hide
    http://www.wix.com/code/reference/$w.Box.html#show

This article has the exact code examples you need

Thank Nayeli,
I think I can figure it out to how to change my code.

Would you have an idea on how to write a code to use the email included in the Database to send an email to all of them?

Pierre Lacasse

Nayeli,
just to confirm if I understand correctly, this code will only deal with the Member Collection (List of registered members in Contacts on the web site) maintained when they Login or Subscribe. It has nothing to do with the database created and maintained by the profile form?

I have created 3 buttons on the Login page.
1- Login/Logout
2- Profile
3- To direct the user to the site itself after he would have Loggedin/Subscribed and fill the Profile.

I have Collapse the site Menu on the Login page and will expand it only if the user has registered/Loggedin AND fill the profile for additionnal information about him.

I would like to do the following:

  • If the user isn’t registered to the Member Collection, then force him to Subscribe and to fill the Profile
  • If he is already registered to the Member Collection, Show him my “Go to button” so he can access the site with the menu Extended

I would like to give access to my site only to registered members that also have filled the Profile

What I want is a Login process that would request additional fialds not just Email and password.

Pierre Lacasse

The article will show exactly what you want to do. It performs a query to see if they exist in your database and it hides/shows elements if they are signed in or not. Here is a video that I created last year to match that article: 2017 Create Member Profile Log In Page - Custom Private Client Member Dashboard - Wix Code - YouTube

For the custom sign up process, here is a thread you may want to read to create your own registration process using the Wix API: https://www.wix.com/code/home/forum/product-updates/custom-member-registration

(I have not watched it yet, but …) A fellow Wix Coder has a video tutorial on that article. This may possibly help you as well: Create a Custom Registration Page with WixCode - YouTube

(Currently you cannot modify the Wix Login window, possibly in the future.)

Nayeli,
I have used the login process you explain in your video. Thank you works perfectly!

Now what should I add to the code so new members have to be authorised before they could be a member of my site?

Thank you much appreciated

Pierre Lacasse

There are different approaches you can take depending on what you want Approved members to see or do.

For example if you want them to sign up but not view the ‘profile’ button until you manually approve them, then one approach would be to add an extra field/column in your database that says something like ‘Approved’ or ‘Access’. Then you can have profile button hide upon login and only appear if ‘Approved’ is checked off or says ‘yes’, etc.

While there are many approaches you can take, the pattern of logic stays the same: hide button/section if a field/column is empty.

Nayeli,
I want to do the same as the Member Login Application does. When the new member fill the Login form and he is not already in the contact list of the site, it goes pending approval until the site owner goes into the contact list of the site and approves it.

Is there a way to do this without adding a new field into the db. What about this function:

I found this in the API references. Can we add this to your code?

Register a user as a site member with manual approval

import wixUsers from ‘wix-users’;
// …
let email = // the user’s email addresses
let password = // the user’s password
wixUsers.register(email, password)
.then( (result) => {
let status = result.status; // “Pending”
let approvalToken = result.approvalToken;
let user = result.user;
} );

Pierre