Get currentUser data in other column from a collection

Is it possible to get currentUser data from other column in a Collection about id/email?

E.g. in my collection there are 2 columns (Name, Category).
If I use currentUser id or email can I do a lookup which comes back with data in Category column based on id/email? (Like flookup/vlookup in MS Excel).

Hi!

Its actually best to filter your users according to their ID.
The ID field has a unique value for every user and so its best to use WixDataQuery to retrieve the specific users data from the collection.

Best of luck!
Doron. :slight_smile:

Thanks a lot!
My code is like that but seems not working.
(I have a button on Members dynamic page to redirect member to an other dynamic page (Requests) based on its Category.)

import wixUsers from ‘wix-users’;
import wixData from ‘wix-data’;
import wixLocation from ‘wix-location’;

export function button2_click() {
wixData.query(“Members”)
.eq(“ID”, wixUsers.currentUser.id)
.eq(“Category”, “category1”)
.find()
.then( (results) => {
if (results.items.length === 1) {
wixLocation.to(/Requests); }

}); 

}

Seems the query never getting any results.
Is my logic wrong?

Hey

I’d be glad to inspect your site and see if I can figure the situation.
Please post a link to the page your facing issues with and I’ll look into it!

Doron. :slight_smile:

The site is only a sketch with functions yet.
I want to show specified content (Requests) for specified members (Members) based on Category.

I collect data to 2 collections:
1, Requests from visitors whit categories
2, Members registrated with his/her category

When a member logging in I want to redirect him/her to a dynamic page (Requests) filtered for only his/her category with a button.

export function button2_click() {
wixData.query(“Members”)
.eq(“ID”, wixUsers.currentUser.id)
.eq(“Category”, “Photographer”)
.find()
.then( (results) => {
if (results.items.length === 1) {
wixLocation.to(/Requestsphotographer); }
});
}