I am working on a company health app that links the user to store health pages that the user creates. I am using a repeater that links to a dynamic page. The dynamic page displays data from the store as well as the logged in users details. but when the user clicks on the repeater and lands on the dynamic page the users details then change to another user in my user data base.
I need to get the current user id from the current logged in user. How do I go about fixing this issue?
It looks like this is the code for the page that links to the dynamic page that you want to display the information. I can see you have a link to the page you mentioned displaying the information on in the code;
This is also not the correct syntax to use when linking to a dynamic page with wixLocation.to(). You should try using wixLocation.to(/stores/${targetId})
Can we see the code you have on page that you want to display your user information? Please also send us a link to your site.
I think the problem is that I am linking from a dynamic page (page 1) which is connected to my (Profile) database (this has the users unique id). On this page i have a repeater with a button that links to a unique item (Store) database:
I am working on a company health app that links the user to store health pages that the user creates. I am using a repeater that links to a dynamic page. The dynamic page displays data from the store as well as the logged in users details. but when the user clicks on the repeater and lands on the dynamic page the users details then change to another user in my user data base.
I need to get the current user id from the current logged in user. How do I go about fixing this issue?
I think the problem is that I am linking from a dynamic page (page 1) which is connected to my (Profile) database (this has the users unique id). On this page i have a repeater with a button that links to a unique item (Store) database:
I don’t think the user ID has anything to do in this case, each dynamic page has at least one field that builds its URL, and that field must be unique for every user and store, so you might consider changing the URL scheme to contain more fields in order to differentiate each dynamic page according to its unique fields.
For example, on the repeater, you need to get the current item that has the clicked button, get the item’s unique fields and set them up as the link of the button.
Here’s an example, we’ll need to use the repeater’s onItemReady() function, let’s say the URL is built with store ID, and the product, and assuming that this repeater displays products from different stores, more like a product gallery.
$w('#repeater').onItemReady( ($item, data) => {
// Get the product ID.
let productId = data._id;
// Get the store identifier (ID or name), we'll go with name
let name = data.name;
// Setting up the button link.
$item('#openProductButton').link = `/shop/${name}/${productId}`;
})
Notice that this line has to be the same as the URL scheme on your dynamic page URL.