wixUsers.currentUser.id

Hi,
I have this site with a Collection named “ListeMembres” that is linked to a dynamic page
Right now, the code that gets to the dynamic page is [wixLocation.to(/ListeMembres/Update/$(wixUsers.currentUser.Id});](wixLocation.to(/ListeMembres/Update/$(wixUsers.currentUser.Id}):wink:

My Collection has the email address unique ie there are no duplicates. I would like to get the dynamic page to display the data based on the email instead of the Id.

What will be the change to my code:
[wixLocation.to(/ListeMembres/Update/$(wixUsers.currentUser.**](wixLocation.to(/ListeMembres/Update/$(wixUsers.currentUser.userEmail});) [**userEmail**](wixLocation.to(/ListeMembres/Update/$(wixUsers.currentUser.userEmail});) [**});](wixLocation.to(/ListeMembres/Update/$(wixUsers.currentUser.userEmail}):wink:
or else

Thank you for your help.

Pierre
ibmretraitesqc

Use getEmail method: https://www.wix.com/corvid/reference/wix-users.User.html#getEmail

import wixUsers from 'wix-users';
import wixLocation from 'wix-location';

$w.onReady(function () {
   wixUsers.currentUser.getEmail().then(email => {
       wixLocation.to(`/ListeMembres/Update/${email}`);
   });
});

But you can have a problem with symbols @ and dot in url. Be carefully )))

Yes, although if they have used the Wix tutorial for own profile as shown here.
https://support.wix.com/en/article/corvid-tutorial-building-your-own-members-area

Then they will be using the site members own unique user id which won’t be duplicated anyway, so why the need to change it to email when it is already unique to the site member and possibly have the hassle with some symbols being changed etc.

Hi thank you for your suggestions. The reason why I want to use email instead of ID is that the collection has an email field and if someone wants to change is email address to something else then it will not connect to my collection. He will create a new userid and password that will create another unique ID.
So by using email then I go the collection, change the email to the new one and bingo the new userid will connect to the right data
Confusing but…

Pierre Lacasse

Just out of curiosity, what email are you thinking of being able to change?

If it is the login email, then you can’t change that as it is a one time choice only.

However you can change other emails that the user supplies if they are wanting to change email address for notifications etc.

Have a look at the Wix Members app details and it will tell you about it there as that is the easiest way to show you.
https://support.wix.com/en/article/adding-a-members-area-to-your-site
https://support.wix.com/en/article/corvid-wix-members-privatemembersdata-collection-fields

@givemeawhisky I know about not being able to change the Login email. What I want is the user creates a new login ID with the new email and I want it to connect to the existing entry in my collection. To do this, I have to change the email in the collection and make sure it links to the new login email
Pierre

Hi, in the same target to change the selection of an item from my collection based from Id to email, I am progressing… Thank you to all!

I use a redirect function and would some advice to switch it from Id to email. Here is part of my code:

function redirect () {
let id = wixUsers.currentUser.id
console.log (id)
getUser(id).then(product => { //This is what you get from the backend
//console.log (product.autorisation)
console.log(product.autorisation)
console.log (product.infoComplet)

Thank you for any help!

Pierre