Light box for registration

I have set up my light box to load on first page the viewer see’s. The registration button, email and password boxes that I have setup is registering new members, but the “.then” function is not redirecting. I had to do a direct link in the button settings to get it to go to the page I wanted.

What I am trying to accomplish is, I would like to have the light box only pop up once per day, per visitor (Non-members). If they are members, I would prefer that the light box not pop up everyday, if the members account is stays logged in.

I also tried to have the “.then” go to the users profile after registering or logging in.
It goes to a “404” page wixLocation.to(’ /profile ');

This is the coded I have set now,

import wixUsers from ‘wix-users’;

import wixLocation from ‘wix-location’;

$w.onReady( function (){

 $w('#registerNow').onClick( **function**  (){ 

let email = $w(‘#registerEmail’).value;

let password = $w(‘#registerPassword’).value;

wixUsers.register(email, password) 

   .then(()=>{ 

       wixLocation.to(' http://thefreekid.com/account/my-account'); 

});

});

});

export function registerNow_click(event) {
wixLocation.to(’ http://thefreekid.com/account/my-account’);
}


Any support would be greatly appreciated, wix support contact referred me here.
My name is Chris and I am the owner of www.thefreekid.com

Hi,
First, if you wish the lightbox replace the Wix Log-In built in system you need to edit your custom signup.
As a result, if a visitor try to get to a member page only the lightbox will automatically pup up.
*pay attention to cancel the automatically display.


View this ticket in order to learn how to edit your custom signup system.

Second, View this code, I believe it will solve the problem:

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

$w.onReady(function () {});

export function registerNow_click(event) {

 let email = $w('#registerEmail').value;
 let password = $w('#registerPassword').value;
    wixUsers.register(email, password)
        .then(() => {
            wixLocation.to(' http://thefreekid.com/account/my-account');
        });

}

Best of luck!
Sapir

You might want to add wix window to above to get it to close lightbox after user registers themselves, although that is probably already covered on the page that Sapir has linked for you.

Below is the code for my own custom register login lightbox, works perfectly and closes after registering details before moving them onto a sign up status page, then both names will be saved in contacts and once site member is approved the member details will be added to my ‘members’ database.

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

Change the URL ending to whatever page you want to send the user to after they log in, as in your case it would be: wixLocation.to(“/account/my-account”);