Context: I am trying to create a membership site with a registration page. The visitor is asked to sign up and then sent to fill our their profile and additional info. I used the how to create member profile pages article for my log in/profile page so most of my site code comes from that.
Now I'd like to either hide a couple 'register' buttons on the home page when members who have completed the form are logged in, or to disable the buttons for said members. I keep getting errors when I attempt to plug in code. My thinking was to use something along the lines of an onReady function with getCurrentItem to check a field (e.g. 'registered'), and if the field was 'x' then the button would hide. Any help would be greatly appreciated as I've spent way too much time trying to figure this out.
panisssss
Hi Ryan,
Welcome to the Wix Code forums.
What have you tried so far and what errors are you getting?
To show or hide a field based on a user login, you might do something like this:
$w.onReady(function () { let user = wixUsers.currentUser; if (!user.loggedIn){ $w(#button1).show(); // show when user logged in $w(#button2).hide(); // show when user not logged in } });
This is a REALLY simple example. All I'm doing is hiding or showing a couple buttons based on a user being logged in.
i would suggest reading about wix-users which will give you all you need to control user logins and page access.
Good luck,
Yisrael