I have this code for if you are a member you can see this button, but i need to refresh the page for see the button when you log in each time
import wixUsers from 'wix-users'; import wixData from 'wix-data'; import wixLocation from 'wix-location'; $w.onReady(function(){ const currentUser = wixUsers.currentUser; if (currentUser.loggedIn && currentUser.role === 'Member'){ //Show components: $w("#button13").show(); } });
This told me it has an error in $w.onReady() => { to down
/import etc... let user = wixUsers.currentUser; function showButton(){ if(user.role === "Member"){ $w("#button13").show(); } } $w.onReady() => { showButton(); wixUsers.onLogin(u => { user = u; showButton(); })
Ohh ok I will try it . By the way, are there one option for roles creates by me? Not admin, member or visitor.
You have to run it on login:
//import etc... let user = wixUsers.currentUser; function showButton(){ if(user.role === "Member"){ $w("#button13").show(); } } $w.onReady() => { showButton(); wixUsers.onLogin(u => { user = u; showButton(); })