Dynamic Page custom re-direct

I have created a custom login, saving the data in a custom “Members” collection to give more flexibility than the standard “Members” app. I pretty much used the code and techniques in the codequeen tutorial (with the login / logout changing buttons). But instead of using user.id as the reference field, I changed the primary field “title” to include the Login Email and am using that as my Dynamic Reference. The page is supposed to go to …/Members/{Login Email} after logging in or when clicking the profile button but am not sure how to reference it. The original code was:

export function profileButton_click(event) {
if (wixUsers.currentUser.loggedIn){
wixLocation.to(/members/${wixUsers.currentUser.id});
}
}

I am currently using:

export function buttonProfile_click(event) {
//if user is logged in
if (wixUsers.currentUser.loggedIn){
//re-direct to profile page
wixLocation.to(Members/{Login Email});
}
}

I only have one entry in my database at the moment, and if i manually go to …wixsite.com/Members/fakeemail%40gmail.com, the dynamic profile page loads fine.

How am I supposed to point to the dynamic page through the code?

Ok, so I have used the “Connect to Data” option to get the button to link to the page. But am still wanting the site to re-direct to the same page immediately after logging in and don’t know how to use wix.Location.to to direct it.

I’m no expert, but I think you’re missing a “/” in your code.
you have wixLocation.to (Members/{Login Email});
I’m pretty sure it should be wixLocation.to (/Members/{Login Email});
Maybe that helps, I don’t know, give it a try =)

If you are talking about @code-queen tutorial from here.
2017 Create Member Profile Log In Page - Custom Private Client Member Dashboard - Wix Code
Of which she updated and republished here.
Creating a client dashboard in Wix using Wix Code
https://codequeen.wixsite.com/membership-dashboard

Then note that this is her take and great thorough explanation on how to get this Wix tutorial to work for you on your own site.
https://support.wix.com/en/article/corvid-tutorial-building-your-own-members-area

However, with your wish of changing from user id to user email, then note that will only work if each site member on your website has their own unique email address and you don’t have site members from the same place for example using the same email address and just simply changing their password only.

This is one reason why using the user id is a better option here as each user id, like the owner id, is unique to each and every specific site member, so you will never have duplicate id values whereas you can easily have duplicate email addresses.

Also, as shown in the pics below, you can’t have dynamic pages which have the same page url, so again having duplicate email addresses will cause you issues as you will identical dynamic pages which won’t work.

Plus, as you are using your own created Members dataset for this, then login email is not available for you as you won’t have it in your Members dataset, you have instead the email field as stated in the Wix tutorial.

Also, if you are wanting to change the Members Profile page and the Members Update Profile page to display email and not id, then you will need to change it in both of the pages settings too.

You will need to click on where it says ID and change it to the field from your dataset that you want, in your case email and which is stated again in the Wix tutorial

Note also in the Wix tutorial that you can’t have the same dynamic page url more than once, each one has to be unique, then that is another reason why you can’t use email and need to be using the id field instead.

As for the Wix Location to link to your page, then as shown in the tutorial, if you stick with the user id then it should be like this.

export function profileButton_click(event) {
wixLocation.to(`/Members/${wixUsers.currentUser.id}`);
}

So to use email you will have to change the .id part of this to .email to suit your page setup

export function profileButton_click(event) {
wixLocation.to(`/Members/${wixUsers.currentUser.email}`);
}

Although, as the tutorial states, you would be much better off sticking with using the id field for each site member.