Question:
Using velo, how do I show the appropriate advanced menu in the header?
Product:
Wix Editor
What are you trying to achieve:
I have 2 advanced menus, one with a “members” entry and one without. Only members who have paid their dues by buying a pricing plan can see the menu with the “members” entry. Others (members who haven’t paid or non members) see the menu without the “members” entry. I want to show the correct menu, depending who has logged in.
What have you already tried:
I’ve tried code in the master page, buit it’s not working. I’ve searched the Internet for days, trying to find something on this issue, but haven’t found anything.
Additional information:
Code from masterPage.js
import wixUsers from 'wix-users';
$w.onReady(() => {
try {
let user = wixUsers.currentUser;
console.log("User: ", user);
user.getPricingPlans()
.then((plans) => {
const paidPlan = plans.find((plan) =>
plan.name === "Individual Join" ||
plan.name === "Individual Renew" ||
plan.name === "Family Join" ||
plan.name === "Family Renew");
if (paidPlan) {
$w("#horizontalMenu3").show(); //menu has "member" area
$w("#horizontalMenu5").hide(); //menu doesn't have "members" area
} else {
$w("#horizontalMenu3").hide();
$w("#horizontalMenu5").show();
}
});
} catch (error) {
$w("#horizontalMenu3").hide();
$w("#horizontalMenu5").show();
console.log("Login Error: ", error);
}
});