What I am trying to achieve is to link a button to dynamic page.
After the user is logged in, a button shows and that button should navigate the user to the respective dynamic pages.
My existing code is
import wixUsers from 'wix-users';
import wixData from 'wix-data';
import wixLocation from 'wix-location';
$w.onReady(function () {
if(wixUsers.currentUser.loggedIn === true) {
$w('#text1').hide();
$w('#text9').hide();
$w('#button1').show(); // this button navigates to the dynamic page
$w('#text15').show();
}
else{
$w('#text1').show();
$w('#text9').show();
$w('#button1').hide(); // this button navigates to the dynamic page
$w('#text15').hide();
}
});
You need to provide more details, what are the fields that are used to build the URL? Is it the profile ID of the member? And if that’s true, are you using the built-in user ID?
Linking a button to dynamic page can also be done like →
let user = wixUsers.currentUser;
let userId = user.id;
wixData.query("UserProfileData")
.eq("userId", userId)
.find()
.then( (results) => {
if(results.items.length > 0) {
let items = results.items[0]['link-userprofiledata-all']; // this is the field of link.
console.log("let items is " + items);
let id = `${items}`
console.log("let id is " + id);
wixLocation.to(`${items}`);
}
} );