wixLocation.to dynamic page with user ID doesn't work

  1. I successfully built up customer log in and sign up page, but I try the code below, it won’t work, and it on works if I used wixLocation.to(‘/account/profile’ instead of
    import wixUsers from ‘wix-users’;
    import wixLocation from ‘wix-location’;

$w.onReady( function (){
$w(‘#submit’).onClick( function (){
let email = $w(‘#input3’).value;
let password = $w(‘#input4’).value;
wixUsers.register(email,password)
.then(()=>{ wixLocation.to(/memberprofile/${wixUsers.currentUser.id});
})
})
})

  1. My sense wix hasn’t updated the current user log in status at the same page, so I just wixLocation to account/profile. I set up a button, and on that page, I coded 2 ways :

export function buttonProfile_click(event) {
wixLocation.to(/memberprofile/${wixUsers.currentUser.id})
}

export function buttonProfile_click(event) {
//wixLocation.to(/memberprofile/${wixUsers.currentUser.id});
//wixLocation.to(‘/home’)
let userId = (wixUsers.currentUser.id);
console.log(userId);
console.log (“/memberprofile” + (userId) +“/”);
wixLocation.to(“/memberprofile/” + (userId) +“/”);
}

Unfortunately, neither of them works.

Hi,

First, verify that you are using the correct dynamic page url. Check out the guide here
https://support.wix.com/en/article/wix-code-about-setting-up-dynamic-page-urls

Second, I am unable to see any code that interacts with the collection that your dynamic page is based on, therefore, make sure that you create the relevant collection record before you try accessing it.