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

How to reload the Page when a user with active access logs in through a Composer Experience Offer?

When you want the page to be refreshed when a converts on a registration term through an Offer in a Composer Experience or logs in and already has access, you can use a callback handler on the loginSuccessevent for this. We do not refresh the page by default.

You can add the following code either to your Piano integration script on your website directly or insert it to the Embed Code under Products → Composer → Integrate → Edit Source.

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();
                }
            }
        }
    });
}]);

Please note, that for users that log in, but do not have any active access, the Offer will remain visible and they may proceed to checkout via a payment term.

Last updated: