Sign up or log in to continue
Gift a Dante's Wine Club Membership
// If user is not logged in, remove 'hidden' class from .modal and .modal-signup
// Function that contains your conditional logic
const modal = document.querySelector('.modal')
const modalSignUp = document.querySelector('.modal_signup')
async function handleMemberStatus() {
const memberstack = window.$memberstackDom;
try {
// Await the result of getCurrentMember()
const { data: member } = await memberstack.getCurrentMember();
if (member) {
// The member is logged in
console.log("Member is logged in:", member.auth.email);
// You can now show protected content or redirect them
// Example: window.location.href = "/dashboard";
} else {
// The member is logged out or doesn't have an account
console.log("Member is logged out.");
// You can now hide protected content or show a login button
modal.classList.toggle('hidden')
modalSignUp.classList.toggle('hidden')
}
} catch (error) {
console.error("Error fetching member status:", error);
}
}
// Check if Memberstack is already ready when the script runs
if (window.$memberstackReady) {
handleMemberStatus();
} else {
// If not ready, wait for the 'memberstack.ready' event
document.addEventListener("memberstack.ready", handleMemberStatus);
}