We’ve migrated our documentation to a new site, which means some URLs have changed.
Subscriptions

How to refresh the Page after a User logs in?

You can use the following code snippet in Piano JavaScript code to check access for logged-in users. If their access is active, the offer template will be closed and the user will be able to access the content of the page.

tp = window.tp || [];
// Hook execute when login was successful
tp.push(['addHandler', 'loginSuccess', function() {
    // Get list of all access data
    tp.api.callApi('/access/list', {}, function(data) {
        if (typeof data.data != "undefined") {
            // Loop through all possible access objects
            for (var i in data.data) {
                // Was access granted?
                if (data.data[i].granted) {
                    // All good, user just logged in, we can close the offer
                    tp.offer.close();
                    // Additionally we can refresh the page
                    location.reload();
                }
            }
        }
    });
}]);

Last updated: