Open a page after correctly sign up

Hey I would like to make if user click submit and sign up correctly, send him to specific page with a form.

I tried something like that

export function button19_click ( event ) {
wixLocation . to ( “/contact” );
}

but it doesn’t send only after successful signup but every time clicking it. How to make that?

Hi,
try the code below.

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

wixUsers . onLogin ( () => {
[wixLocation](wixLocation.to(https://MYSITE/account/my-account);
})) [.](wixLocation.to(https://MYSITE/account/my-account);
})) [to](wixLocation.to(https://MYSITE/account/my-account);
})) [(](wixLocation.to(https://MYSITE/account/my-account);
})) [https://MYPAGE](wixLocation.to(https://MYSITE/account/my-account);
})) [);](wixLocation.to(https://MYSITE/account/my-account);
}))
[})](wixLocation.to(https://MYSITE/account/my-account);
}))

Put the correct page in the url.

Another possibility is that you check first if the user is logged in. If YES, then you give him the possibility to push the button.
If you want to go on in this direction I can post some example.
David

Hi there :wave:t2: I do this on my site. I can’t tell if your question is about user register or user login , so I’ll give both cases. It would be helpful to see your whole code for the page, but the code below is the structure that I use. You will of course need to change the element IDs to match yours.

For Register

When the button is clicked, register the user.
If the registration is successful, send them to a specific page.
If not successful, there is an error.

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

$w.onReady(function () {
       // When the button is clicked
    $w('#yourRegisterButton').onClick(function () {
        let email = $w("#registerEmail").value; // Email element ID
        let password = $w("#registerpassword").value; // PW element ID
        // Register the user
        wixUsers.register(email, password)
            .then((result) => {
                let resultStatus = result.status;
                console.log(resultStatus);
                // If registration is successful, send to the page below
                wixLocation.to("/contact");  
            })
            // If registration NOT successful, send an error
            .catch((err) => {
                console.log(err);
            });
    });
});

For Login

When the button is clicked, login the user.
If the login is successful, send them to a specific page.
If not successful, there is an error.

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

$w.onReady(function () {
       // When the button is clicked
    $w('#yourLoginButton').onClick(function () {
        let email = $w('#loginEmail').value; // Email element ID
        let password = $w('#loginPass').value; // PW element ID
        // Login the user
        wixUsers.login(email, password)
           .then(() => {
               // If login is successful, send to the page below
               wixLocation.to("/contact");
        })
         // If login NOT successful, send an error
        .catch((err) => {
            console.log(err);
        });
    });
});

You could also check out these resources for more info and examples:

Thank you so much! It works as I wanted :smiley: