# Custom log out problem on a Dynamic  member page

**URL:** <https://forum.wixstudio.com/t/custom-log-out-problem-on-a-dynamic-member-page/5032>\
**Category:** Ask the community\
**Tags:** wix-members-area, code, question\
**Created:** [November 3, 2021, 6:40pm UTC](https://forum.wixstudio.com/t/custom-log-out-problem-on-a-dynamic-member-page/5032 "2021-11-03T18:40:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hjas111](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/hjas111/32/30734_2.png) [@hjas111](https://forum.wixstudio.com/u/hjas111)\
**Post date:** [November 3, 2021, 6:40pm UTC](https://forum.wixstudio.com/t/custom-log-out-problem-on-a-dynamic-member-page/5032/1 "2021-11-03T18:40:56Z")

</div>

Hey!

So I’ve created a custom member area for my site, and have not used the Wix native one. My problem is more or less a bug in my opinion but it frustrates me a bit so I’m curious if it’s a code problem from my side or it’s because you can’t do a workaround in some cases.  
I’m using a button for login or log out and it works perfectly fine on every page except on the user dynamic page because when I want to log out it does not take me to my homepage but redirects me to Wix native login/register page, and when only after I close this page, then it shows my homepage and I’m not quite sure why the code doing this only on my dynamic user page.

Thats the code from the masterPage.js file

import { session } **from** ‘wix-storage’ ;  
import wixLocation **from** ‘wix-location’ ;  
import wixData **from** ‘wix-data’ ;  
import wixUsers **from** ‘wix-users’ ;  
import { authentication } **from** ‘wix-members’ ;

//log in / log out button labels and changes

$w . onReady (() =\> {  
**if** ( wixUsers.currentUser.loggedIn ) {  
$w ( “#loginbutton” ). label = “Kijelentkezés” ;  
$w ( “#ProfileButton” ). show ();  
$w ( “#secretlogbutton” ). hide ()  
} **else** {  
$w ( “#loginbutton” ). label = “Bejelentkezés” ;  
$w ( “#ProfileButton” ). hide ();  
$w ( “#secretlogbutton” ). show ();  
$w ( “#loginbutton” ). hide ();  
}

$w . onReady ( **function** (){  
$w ( ‘#loginbutton’ ). onClick ( event =\> {  
// user is logged in  
**if** ( wixUsers.currentUser.loggedIn ) {  
// log the user out  
authentication . logout ()  
. then (() =\>  
{  
// update buttons accordingly  
$w ( “#loginbutton” ). label = “Bejelentkezés” ;  
$w ( “#ProfileButton” ). hide ();  
$w ( “#loginbutton” ). hide ();  
$w ( “#secretlogbutton” ). show ();  
});  
}

})})});
