please help,
i add this code according to this video step by step
https://support.totallycodable.com/en/article/create-custom-log-in-sign-on-screen-using-wix-code
but when i preview nothing work, i dont understant why
this is the code :
import wixUsers from ‘wix-users’;
import wixLocation from ‘wix-location’;
import wixWindow from ‘wix-window’;
$w.onReady( function () {
$w(“#forgetPassword”).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(“/website/activities”); //Change the URL ending to whatever page you want to send the user to after they log in.
} )
. catch ( (err) => {
console.log(err);
} );
}
With the Wix Users API don’t test it out just in preview mode, you need to test it on a fully published site.
Note
The APIs in wix-users are only partially functional when previewing your site. View a published version of your site to see their complete functionality.
The APIs in wix-users can only be used once the page has loaded. Therefore, you must use them in code that is contained in or is called from the onReady() event handler or any element event handler.
its not working even on a publish mode, the login button dont react at all… why?
That code is from Nayeli (Code Queen) and is not part of Wix’s own tutorial’s.
However, Nayeli is great help and I have used her code support a good few times and have no trouble following her tutorials or youtube videos.
I have used this code for my own login lightbox and mine works just fine. Make sure that you go through and double check all of the steps.
Plus, make sure that you watch the youtube video of the tutorial too if you are still struggling.
https://www.youtube.com/watch?v=QbH8_eudjbE
This is my own code for it and it all works fine.
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.
} );
}
Also, have you simply not added the onClick event to the login button element through its properties panel?
i did everything… can you share with me your editor? maybe i missed something
If you have followed the tutorial and followed the tutorial video as well, then it should all be working fine by now.
I suggest that you go over everything carefully and double check that everything is set up as it should be.
You can paste your full Wix Editor url address here, however it is only Wix personnel like @yisrael-wix (Admin) or other Wix Mods here who have the authority to access your Editor to check it.
Or better still, send a question to @code-queen herself as it is her tutorial and code that you are using to do this.
@givemeawhisky I have followed exactly the the tutorial as mentioned here, however when I enter a correct t email and password I get this:
@niallmagner
If you have created your own custom lightboxes for login and signup, then you need to set up your member signup settings to suit too.
https://support.wix.com/en/article/corvid-enabling-custom-site-registration
Also, when you use this url address in your code - wixLocation.to (“/account/my-account”); - it is looking for the My Account page which is from the Wix Members app which you need to have added to your own website if you want to use it.
https://support.wix.com/en/article/adding-a-members-area-to-your-site
Any pages from the Wix Members app will have the prefix of /account/pageurl, so if you are wanting your user to go to another page, then you simply need to do something simple like wixLocation.to (“/yourpageurl”);
@givemeawhisky Well I created my own login page. I think there are some users like me who are not familiar with lightboxes in regards to customizing login: