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

How to get Custom fields data on the frontend

Piano provides a JavaScript function tp.pianoId.loadExtendedUser which starts the loading of the current user's custom fields. Once received, the data about the user's profile will be passed via the extendedUserLoaded callback.

By default, only custom fields from the My account form will be returned. To return a specific set of fields, you should:

  1. Create a custom form called new_form (or any custom name, but you need to keep it consistent in the further steps)

  2. Add the required Custom fields in the form called new_form

  3. Use the form_name parameter in the callback loadExtendedUser. For example:

    tp = window.tp || [];
    tp.pianoId.loadExtendedUser({
        extendedUserLoaded: function (data) {
            for (var i in data.custom_field_values) {
                var fieldName = data.custom_field_values[i].field_name;
                var fieldValue = data.custom_field_values[i].value;
                console.log("Field " + fieldName + " has value " + fieldValue);
            }
        }, formName: 'new_form'
    });
    

Last updated: