Listen to permission level changes from your own code

In order to immediately react on a permission change it is possible to subscribe to an event using JavaScript. The example script below makes sure the current page will be reloaded so conditional content will be visible or hidden. A timeout is necessary to make sure other event listeners have finished before reloading the page.

<script type="text/javascript"> 
    var bcSubscriptions = bcSubscriptions || [];
    bcSubscriptions.push(['onPermissionLevelChange', function(event, context)  {
        try {
            // Reload page so that any personalized content will become available.
            // Delay the reload by 500ms to make sure other event listeners have finished
            setTimeout(function() {
            location.reload(true);
            }, 500);
         } catch(err) { }
`    }]);
</script>