Hi, I want to add to my member area a place they can input their weekly measurement and also to see all the past measurements.
can you help me with that?
To only show the measurements for a particular member, you can filter the data displayed in the repeater element based on the member’s unique identifier. In your database collection, add a field to store the unique identifier for each member (e.g., an email address or a member ID). In the input form, add a hidden field to store the unique identifier of the currently logged-in member. You can use the wixUsers.currentUser.id function to get the current user’s ID. When the form is submitted, store the current user’s ID in the hidden field so that it is saved to the database along with the measurement data. On the page that displays the measurements, add a repeater element to display the data from the database. In the repeater element’s data panel, set the data source to the database collection and use a filter to only show the records where the unique identifier field matches the current user’s ID. You can use the wixUsers.currentUser.id function to get the current user’s ID.
Try out:
import wixData from 'wix-data';
import wixUsers from 'wix-users';
$w.onReady(function () {
// ...
let user = wixUsers.currentUser;
let userId = user.id; // "r5cme-6fem-485j-djre-4844c49"
let isLoggedIn = user.loggedIn; // true
let userRole = user.role; // "Member"
user.getEmail()
.then((email) => {
let userEmail = email; // "user@something.com"
console.log(userEmail);
console.log(userId);
$w("#dataset1").setFilter(wixData.filter()
.eq("email", userEmail)
);
});
});
If I could help you, please put my article as “Best Answer”. Thanks
Thanks a lot.
do I also need a code to connect both data base?
And for what you mention above do i need another code?