All of my users have to log in for entering the website. All members details are stored into a Directory DB.
I created a form (attached) for each member to adjust / update their details. When the form loads, I want the existing details of the specific member (who has previously logged in) to load and not the details of some other members.
I guess it is only very few code lines but I cannot figure out which ones when I read all posts and articles already published. Can anybody assist me?
Thanks a lot
All good, thank you very much
Okay, you're getting there. I think what you want is something more like this:
$w("#dataset1").onReady( () => { // get the current user's email wixUsers.currentUser.getEmail() .then( (email) => { // set the filter to only show items where "email" field //matches current user's email $w("#dataset1").setFilter( wixData.filter() .eq("email", email) ) } ); );
Here is what I tried. I identify through the email address and try to filter with it, the email being the only read-only field in the form. But this still does not set the proper details of the logged-in user.
QUOTE
import wixUsers from 'wix-users';
import {wixData} from 'wix-data';
$w.onReady(function () {
$w("#dataset1").setFilter( wixData.Filter() );
$w("#dataset1").onReady( () => {
let currentEmail = $w("#dataset1").getCurrentItem().email;
wixUsers.currentUser.getEmail()
.then( $w("#dataset1").setFilter( wixData.filter()
.contains("email"))
);
} );
} );
UNQUOTE
Thanks a lot
You can filter the page's dataset based on the current user.
You get the current user information from the wix-users API. And you filter a dataset using the wix-dataset setFilter( ) function.
It is a regular page. Thanks a lot
This is very similar to what we describe in the new article How to Create Member Profile Pages.
How you do this will depend on what kind of page the form is on. Is it a regular page or a dynamic page?