Custom Sign Up problems with database

i wanted to connect my custom sign up form to my own database, a few while ago it worked just fine and now its not. People signed up but after their data got submitted to my database, they didn’t automatically signed up to the website, at that point is where i’m confused. Supposedly visitors would automatically signed up to the web after they sign up, but now it doesn’t and they can’t log in even though supposedly the log in database takes the info from sign up database.
Does this have anything to do with the privatemembers database? I’m very sure it wasn’t there a few while ago. If yes, how do i make it so the sign up and login form logs people in by my own database and not private members database?


Here is my code for custom sign up.

import wixUsers from ‘wix-users’;
import wixWindow from ‘wix-window’;
import wixLocation from ‘wix-location’;

$w.onReady( function () {

$w("#register").onClick( (event) => { 

let email = $w(“#email”).value;
let password = $w(“#password”).value;

wixUsers.register(email, password, {
} )
.then( (result) => {
let resultStatus = result.status;
wixWindow.lightbox.close();
wixLocation.to.to(“/welcome”); //Change the URL ending to whatever page you want to send the user to after they log in.
} );
} );

});

And here is my custom log in code

import wixUsers from ‘wix-users’;
import wixLocation from ‘wix-location’;

$w.onReady( function (){
$w(‘#login’).onClick( function (){
let email = $w(‘#loginEmail’).value;
let password = $w(‘#loginPassword’).value;
wixUsers.login(email,password)
.then(()=>{
wixLocation.to(‘/registration’);
})
})
})

All depends on how you have your site member approval set up, manual then you have to approve themselves, automatically then they become site members immediately.
https://support.wix.com/en/article/approving-a-site-member
https://support.wix.com/en/article/request-receiving-email-notifications-for-automatically-approved-new-site-members
https://support.wix.com/en/article/editing-your-member-signup-settings-for-the-default-form

If Site Members is configured for automatic approval , the register() function returns a status of "Active"and the user becomes an active member of the site.

If Site Members is configured for manual approval , the register() function returns a status of “Pending” and the user becomes a pending member of the site. In order to activate a pending user, the site owner can approve the user manually , using the Contacts application or you can call the approveByToken() or approveByEmail() functions.

https://www.wix.com/corvid/reference/wix-users.html#register

Signup lightbox code.

import wixUsers from 'wix-users';
import wixWindow from 'wix-window';
import wixLocation from 'wix-location';

$w.onReady(function () {
    
    $w("#registerButton").onClick( (event) => {
        
   let email = $w("#email").value;
   let password = $w("#password").value;
   let first = $w("#firstName").value;
   let last = $w("#lastName").value;

   wixUsers.register(email, password, {
       contactInfo: {
        "firstName": $w('#firstName').value,
        "lastName": $w('#lastName').value,
       }
      } )
      .then( (result) => {
        let resultStatus = result.status;
  wixWindow.lightbox.close();
  wixLocation.to("/sign-in-status");  //Change the URL ending to whatever page you want to send the user to after they log in.
      } );     
    } );
    
});

Login lightbox code.

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_click(event) {

 let email = $w("#email").value;
 let password = $w("#password").value;

 wixUsers.login(email, password)
   .then( () => {
     console.log("User is logged in");
     wixLocation.to("/account/my-account");  //Change the URL ending to whatever page you want to send the user to after they log in.
   } )
    .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.
   } ); 
}

Login lightbox code that automatically refreshes the page that the lightbox appears on after the user is logged in and the lightbox closes automatically.

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.
   } ); 
}

@givemeawhisky thank you! the sign up code works perfectly, but my log in stays the same, i clicked log in and it doesnt go anywhere, no error messages too. i used the auto-closed code

Very simple, just use the right code in your login lightbox.

If you are wanting to redirect your user onto another page after they login then simply do that in the code.
[wixLocation.to(“/account/my-account”);](code.
wixLocation.to(“/account/my-account”);

If)
Or whatever page URL that you want the user to go to on your site.

If you are wanting the user to stay on the same page that the lightbox appeared on then just use this code.
[wixLocation.to(wixLocation.url);](wixLocation.to(wixLocation.url);

This)
This will refresh the page that the user was on already, so if you don’t need the page to be refreshed then just simply take out this line and have the lightbox close only.

still doesn’t work… i wonder if it’s something else that is the source of the problem but i can’t find what it is