I used a solution in https://www.wix.com/velo/forum/coding-with-velo/create-custom-member-page-unique-to-each-user-1 this post, but it didn’t work for me.
Here is what I have.
import wixUsers from ‘wix-users’ ;
import wixData from ‘wix-data’ ;
$w . onReady ( function (){
$w ( "#Section2Repeater1" ). show (); //your repeater ID
let user = wixUsers . currentUser ;
let userEmail ;
user . getEmail (). then ( ( email ) => {
userEmail = email ;
console . debug ( userEmail )
$w ( “#dataset1” ). onReady (() => {
$w ( “#dataset1” ). setFilter ( wixData . filter ()
. eq ( “email” , userEmail )
)
})
});
});
What should I do?
When i look onto your code, my first thoughts are…
-
You are using the DEPRICATED → Wix-Users-API → This happens when you copy your code from old posts.
-
Notmaly i would say → never try to mix DATASET + Wix-Data-Api together, especially if you are a total beginner → this always ends in CHAOS and DESASTER (as you can see).
But in your case, both maden MISTAKES are ok.
The old Wix-UsersAPI should normaly still work (anyone knows for how long) and you can use it.
Also the mixing of DATASET and Wix-Data-Api isn’t that big FAILURE in your case.
First what you should check, would be the result of…
let user=wixUsers.currentUser; console.log(user);
What do you get here as ressult?
Next step would be to check next code-line for result…
user.getEmail().then((email)=>{
userEmail=email; console.log(email);
});
What do you get here as ressult?
Try to start your code like this…
$w.onReady(function(){
$w("#dataset1").onReady(()=>{
});
});
A better way to set a filter…
let filter = wixData.filter();
filter.eq("email", userEmail)
$w("#dataset1").setFilter(filter);
I’m trying this now. It is not working properly.
import wixUsers from ‘wix-users’ ;
import wixData from ‘wix-data’ ;
$w . onReady ( **function** (){
//your repeater ID
$w ( "#dataset1" ). onReady (()=>{
**let** user = wixUsers . currentUser ;
user . getEmail (). then (( email )=>{
**let** userEmail = email ;
**let** filter = wixData . filter ();
filter . eq ( "email" , email )
$w ( "#dataset1" ). setFilter ( filter );
});
});
});
What exactly does not work?
Which errors do you get?
Please always try to describe your problem as much detailed as possible.