hi @digitaldarwin it is straight forward process once you will have isUserLoggedIn to be true
or false
you can do anything you need.
simple example will looks like this
<script>
// Simulate the user sign-in state
var isUserLoggedIn = false; // Set to true or false manually for testing
// Wait for the DOM to load
document.addEventListener("DOMContentLoaded", function() {
// Get elements by their IDs
var signInLink = document.getElementById("sign-in");
var registerLink = document.getElementById("register");
var signOutLink = document.getElementById("sign-out");
// Control visibility based on the sign-in state
if (isUserLoggedIn) {
// User is signed in: show 'sign-out', hide 'sign-in' and 'register'
signOutLink.style.display = 'block';
signInLink.style.display = 'none';
registerLink.style.display = 'none';
} else {
// User is not signed in: show 'sign-in' and 'register', hide 'sign-out'
signOutLink.style.display = 'none';
signInLink.style.display = 'block';
registerLink.style.display = 'block';
}
});
</script>
If conditionally visible links are inside dropdown that contain permanently visible links you can for example set attribute like “isVisible” on conditional links and based on isUserSignedIn change false
to true
toggle their visibility .
Please refer to this response how to get logged user info: