Question:
Is it possible to hide a section when member is logged in?
Product:
Velo
What are you trying to achieve:
I want a section to disappear when they have already signed in. If the user it is not signed in, the section should be visible.
What have you already tried:
used this code, but didn’t work:
import wixUsers from 'wix-users';
$w.onReady(function () {
// Check if the current user is logged in
wixUsers.onLogin(function (user) {
if (user.loggedIn) {
// User is logged in, hide the section
$w('#create_account_1').hide();
} else {
// User is not logged in, show the section
$w('#create_account_1').show();
}
});
});
Additional information:
[Include any other pertinent details or information that might be helpful for people to know when trying to answer your question.]
Is it possible to hide a section when member is logged in?
Yes, this is possible.
import wixUsers from ‘wix-users’;
Wix-Users-API is a depricated one → you shouldn’t use it anymore.
Thisfor you have the new Wix-Members-API.
First read the API and try to solve your problem by yourself.
Also take a look onto the numerous examples given inside of this forum.
Similar problems you can find in this post…
Hi team, I hope you are all doing great.
I have attached this code to my Dev Tool>
import wixUsers from ‘wix-users’ ;
$w . onReady ( () => {
if ( wixUsers . currentUser . loggedIn ) {
$w ( ‘#loginbutton2’ ). hide ();
}
else {
$w ( ‘#loginbutton2’ ). show ();
}
});
but, once I logged in the site kept showing me the button, if I reload the page then the button hides but it is supposed to hide as soon as I log in right?
Thanks for your help
This one could be useful for you…
Open your MASTER-PAGE and add the following into it…
MASTER-PAGE-CODE:
import wixMembers from 'wix-members';
$w.onReady(async()=>{console.log("Master-Page running...");
//-----On-Login-Section-----------------------------------
wixMembers.authentication.onLogin(async(member)=> {
console.log("MEMBER: ", member);
let memberData = await member.getMember();
console.log('MEMBER-Data: ', memberData);
const memberRoles = await member.getRoles();
…
Maybe this one too…
I’m unable to get the following code to assign a role to members upon registration. Would really appreciate if anyone could please point out what’s wrong. Thanks!
// Custom signup
import { authentication } from 'wix-members';
import { assign } from 'backend/role';
$w.onReady(function () {
// Click "Run", or Preview your site, to execute your code
$w('#button2').onClick ((event) => {
const email = $w('#input2').value;
const password = $w('#input1').value;
const…
…or this one…
My friend and I are designing a sports-themed website, and we want to add a feature that allows you to click a button and “vote“ for who will win a particular matchup, but we are having difficulty tracking which specific user clicks a button instead of just general responses.
The ultimate goal is to allow players to click whatever team they prefer and allow us to track responses so we can reward correct answers after games are played.
If anyone has knowledge on how to do so, it’d be greatly ap…
…or this OLD BUT GOLD ONE ???
Hello, I’d like to make something where it senses how many people are on a page and if there are none, it clears all fields in the page’s dataset.
If you click on the ‘enter’ button, it redirects you to a page with an empty dataset and no users. If there are no free pages, a message can appear on your screen. How can I do that?