Help! Create custom login to a dynamic members page.

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

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(); 
   } ); 
}

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 and make sure the right fields have been set up to match the URL you’re redirecting to.

Here’s an example:

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 for more info.

Hope this works out for you!

Best regards,

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 .be/2AR5FTq43to for my registration page, but unfortunately he don´t shows how to create a login page for this.

/ Thank you for replying