Hi, I’m trying to solve this for a few days now. What I need is to read the user member role (Ambassador), created in the roles section of the Dashboard and use a button to send the user to a specific location. When the role is different, the button remains the same but the location changes.
So far I’m not getting a single result! HELP!!!
import wixUsers from ‘wix-users’;
import wixLocation from ‘wix-location’;
let url = wixLocation.url; let user = wixUsers.currentUser; let userId = user.id; // “r5cme-6fem-485j-djre-4844c49” let isLoggedIn = user.loggedIn; // true
// this is where the button gets displayed if the user is a member
Hi, I tried to use that but it returns a parsing error
import wixUsers from ‘wix-users’; import wixLocation from ‘wix-location’;
let url = wixLocation.url; let user = wixUsers.currentUser; let userId = user.id; // “r5cme-6fem-485j-djre-4844c49” let isLoggedIn = user.loggedIn; // true
You need to make sure that you go through your code and check that your code has matching pairs of open and closed curly brackets ( ‘{’ and ‘}’) as well as matching pairs of parentheses (‘(’ and ‘)’).
@jonatandor35 Thanks JD I just did but the code still doesn’t work. I’m getting a bit desperate here ahahah.
Supposedly the role [0] should be the role assigned to the user since it only has one assigned member role but I can’t really find my way around this thing
@jonatandor35 Hey JD, first, thanks for trying to help… I’m really not understanding what am I doing wrong here. I applied your code but I still get a parsing error
@J. D. HEy man, sorry to bother you one more time I tried the code yesterday and it all seemed to work just fine for one role but adding a second one completely threw the code off. I have a different approach that should work:
I have one button for each role which is hidden on load and that should appear when the respective role is signed in. So far I only get the same button to appear, independent of who is logged in Would you take a look?
import wixUsers from ‘wix-users’; import wixLocation from ‘wix-location’;
let user = wixUsers.currentUser; let url = wixLocation.url; let userId = user.id; // “r5cme-6fem-485j-djre-4844c49” let isLoggedIn = user.loggedIn; // true
Even tried to clean it but even when the user is an “influencer” it shows me the button for ambassador.
import wixUsers from ‘wix-users’; import wixLocation from ‘wix-location’;
let user = wixUsers.currentUser; let url = wixLocation.url; let userId = user.id; // “r5cme-6fem-485j-djre-4844c49” let isLoggedIn = user.loggedIn; // true