# Custom Login Error Message Issue

**URL:** <https://forum.wixstudio.com/t/custom-login-error-message-issue/25185>\
**Category:** Ask the community\
**Tags:** code, question\
**Created:** [April 21, 2020, 10:54pm UTC](https://forum.wixstudio.com/t/custom-login-error-message-issue/25185 "2020-04-21T22:54:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sktvinc](https://avatars.discourse-cdn.com/v4/letter/s/e56c9b/32.png) [@sktvinc](https://forum.wixstudio.com/u/sktvinc)\
**Post date:** [April 21, 2020, 10:54pm UTC](https://forum.wixstudio.com/t/custom-login-error-message-issue/25185/1 "2020-04-21T22:54:24Z")

</div>

Hello,

On my custom login, the error message is not appearing when an incorrect login is triggered.  
Everything else works fine except for that. I think it’s in the wrong place in the code, but I do not know anything about coding and have gotten the code from a tutorial. Can someone fix my code and send it back to me? Thank you so much if you can!

Here is the 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](https://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( “#loginEmail” ).value;  
**let** password = $w( “#loginPassword” ).value;

wixUsers.login(email, password)  
.then( () =\> {  
console.log( “User is logged in” );  
wixLocation.to( “/login” ); //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.  
} );  
}

$w.onReady( **function** () {  
$w( “#loginPassword” ).onKeyPress( (event) =\> {  
**let** key = event.key; // “Enter”  
**let** email = $w( “#loginEmail” ).value;  
**let** password = $w( “#loginPassword” ).value;

wixUsers.login(email, password)  
.then( () =\> {  
console.log( “User is logged in” );  
wixLocation.to( “/login” ); //Change the URL ending to whatever page you want to send the user to after they log in.  
} )  
} )  
} );

$w.onReady( **function** () {  
$w( “#loginEmail” ).onKeyPress( (event) =\> {  
**let** key = event.key; // “Enter”  
**let** email = $w( “#loginEmail” ).value;  
**let** password = $w( “#loginPassword” ).value;

wixUsers.login(email, password)  
.then( () =\> {  
console.log( “User is logged in” );  
wixLocation.to( “/login” ); //Change the URL ending to whatever page you want to send the user to after they log in.  
} )  
} )  
} );
