# Help! Create custom login to a dynamic members page.

**URL:** <https://forum.wixstudio.com/t/help-create-custom-login-to-a-dynamic-members-page/41079>\
**Category:** Ask the community\
**Tags:** wix-members-area, code, question\
**Created:** [August 20, 2020, 2:42pm UTC](https://forum.wixstudio.com/t/help-create-custom-login-to-a-dynamic-members-page/41079 "2020-08-20T14:42:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![oscar03](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/oscar03/32/22900_2.png) [@oscar03](https://forum.wixstudio.com/u/oscar03)\
**Post date:** [August 20, 2020, 2:42pm UTC](https://forum.wixstudio.com/t/help-create-custom-login-to-a-dynamic-members-page/41079/1 "2020-08-20T14:42:45Z")

</div>

I`m trying to make a custom login to a dynamic mebers page with some code from several youtube clips, but it doesn´t work. If I try to login via a profile in my database, it returns 404. I´m not an expert on coding so I would be grateful if someone can edit my code. /Thanks

```javascript
import wixUsers from 'wix-users';
import wixLocation from 'wix-location';
import wixWindow from 'wix-window';

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(`/members/${wixUsers.currentUser .id}`); 
   } )
    .catch( (err) => {
     console.log(err);
     $w("#errorMessage").expand(); 
   } ); 
}

```

---

<div class="post-metadata">

**Author:** ![mrtobor](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/mrtobor/32/669_2.png) [@mrtobor](https://forum.wixstudio.com/u/mrtobor)\
**Post date:** [August 20, 2020, 4:05pm UTC](https://forum.wixstudio.com/t/help-create-custom-login-to-a-dynamic-members-page/41079/2 "2020-08-20T16:05:53Z")

</div>

Hello,

Your code seems fine except for the spacing between **currentUser** and **.id**.  
Once you fix that you’ll need to check your [dynamic page’s URL](https://support.wix.com/en/article/creating-a-unique-dynamic-page-url) and make sure the right **fields** have been set up to match the URL you’re redirecting to.

Here’s an example:

 ![](https://us1.discourse-cdn.com/wix/original/3X/3/2/325d26330be0438025da0a1e42ce1d4bb9453863.jpeg)

The important thing to note here is the URL, notice the ID field has been added to the URL from the privateMembersData collection.

Once the URL matches the code it should work after publishing your site. You can always refer to [this article](https://support.wix.com/en/article/corvid-tutorial-building-your-own-members-area#profile-page) for more info.

Hope this works out for you!

Best regards,

---

<div class="post-metadata">

**Author:** ![oscar03](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/oscar03/32/22900_2.png) [@oscar03](https://forum.wixstudio.com/u/oscar03)\
**Post date:** [August 23, 2020, 1:44pm UTC](https://forum.wixstudio.com/t/help-create-custom-login-to-a-dynamic-members-page/41079/3 "2020-08-23T13:44:21Z")

</div>

Thank you for you help Miguel!  
I have tried to login but it still not works. When I create a user with an email it gets an ID in my “members” datebase but when I try to login it takes me to another ID, but the same ID everytime I try. It looks like there is no connection between the registered email and ID and the login email and ID. So I wonder if I do not need to write something like “import id” in my code? I have used this video [https://youtu](https://youtu) .be/2AR5FTq43to for my registration page, but unfortunately he don´t shows how to create a login page for this.

/ Thank you for replying
