When the user clicks on the Login button I'd like them to be directed to their dynamic Member page:
Here is the page code:
import wixLocation from 'wix-location'; $w.onReady(function(){ $w('#loginNow').onClick(function (){ let email = $w('#loginEmail').value; let password = $w('#loginPassword').value; wixUsers.login(email,password) .then(()=>{ wixLocation.to('/Member/${_id}'); }) }) })
Here is the page settings for the dynamic page:
Here is the ID field in the Member database:
The login button seems to work if it's directed to a different page. For example if I want to send the user to the shop page:
wixLocation.to('/shop'); <--- This seems to work
wixLocation.to('/Member/${_id}'); <--- This does not work :(
Any help is greatly appreciated!
FD
did you ever figure out a solution? i've been looking all over
did you ever figure out a solution? i've been looking all over
Hi !!
In your database, you should have a field of url like this ->
Click on the 'properties' and get the field key......
Get the field key and ->
wixData.query("UserProfileData") .eq("userId", userId) .find() .then( (results) => { if(results.items.length > 0) { let items = results.items[0]['link-userprofiledata-title']; //field key console.log("let items be " + items); let id = `${items}` console.log("let id is " + id); wixLocation.to(`${items}`); } });
Hey there,
I am trying to create the same thing. However, the URL does not accept special characters (% or $). Has anyone had this issue? If so, how do I get around it? This is my first time building a website so I am definitely open to any suggestions, besides hiring someone to do it for me.
Hi Josh,
If you create your own member area according to this tutorial, you miss the line that get the current user ID.
https://support.wix.com/en/article/wix-code-tutorial-building-your-own-members-area#login-page
import wixLocation from 'wix-location'; $w.onReady(function(){ $w('#loginNow').onClick(function (){ let email = $w('#loginEmail').value; let password = $w('#loginPassword').value; wixUsers.login(email,password) then(()=>{ wixLocation.to(`/Members/${wixUsers.currentUser.id}`); }) }) })
Best,
Sapir