Logged In Variable
This page shows how you can use the Logged in Global Variable to display details or hide details on a page.
In this particular case, we are hiding access to a PDF download unless the User is logged in!
You are NOT Logged in!
You ARE logged in!
How It’s Done
There are two parts to this:
- The HTML which contains named elements
- The JavaScript that hides or shows the elements based on the presence of the MBB.data.lacid variable which will indicate that the Lead is Logged in.
<div class="bfg-not-logged-in">
You are NOT Logged in!
</div>
<div class="bfg-logged-in">
You ARE logged in!
</div>
The JavaScript
jQuery(document).on("mbb-widgets-loaded", function() {
if ( MBB.data.lacid ) {
$(“.bfg-logged-in”).show() ;
$(“.bfg-not-logged-in”).hide() ;
} else {
$(“.bfg-logged-in”).hide() ;
$(“.bfg-not-logged-in”).show() ;
}
});
[easyembed field=”script”]