How can I hide and show elements for specific members?

I have a member page on my website and I have added a gallery, user input text box, and submit button. I have created a data collection that contains email, images, etc. I want a code that gets the current user email and searches for it in my data collection and if it finds then it shows the elements like gallery, user input text box, etc and if it doesn’t finds email in that collection then it just shows no results found.

Hi Shash,

Can you be a bit more specific with what you need help?

Do you have some sort of code already?
Ifso, what did you try, what code do you use and doesn’t work.
Do you need help with all or just to get the current users email?

Kind regards,
Kristof.

HI Kristof,

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

$w . onReady ( async function () {
let user = wixUsers . currentUser ;
let myQuery = await wixData . query ( “Results” )
user . getEmail ()
. then ( ( email ) => {
let userEmail = email ;
} );

myQuery . eq ( “_newFeild” , user )
$w ( ‘#gallery1’ ). show ();
$w ( ‘#textBox1’ ). show ();
$w ( ‘#button52’ ). show ();

});

I am using this code. I just want to check that does current logged-in user email is present in my data set collection or not if the currently logged-in user email is present in the dataset collection then I want to show elements to them otherwise not. Also, I have set the default value of the elements to collapsed so that the elements load only for those users whose email is present in the dataset collection.

Kind regards,
Shrey.

@shashdigital0
There are so many posts which handles and solves your question.
For example just answered a similar question here some minutes ago…
You should use more the → SEARCH ← of this FORUM!

All you have to do are just 3 or 4 steps…

  1. Get current USER-DATA first…
    https://www.wix.com/velo/reference/wix-users/currentuser
  2. Take the found eMail and search for it in your DB…
    https://www.wix.com/velo/reference/wix-data/query
    • —> .eq(DATAFIELD, VALUE) → eq = equals
  3. .then(( RESULTS )=>{ → you get results here at this part of CODE.
  4. add a little CONSOLE-LOG to see results in CONSOLE…
    .then(( RESULTS )=>{ console.log(results);
  5. continue…

And do not forget, everything depends on the structure of your DB.
How is structured your DB ?