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:
-
Create a custom form called
new_form(or any custom name, but you need to keep it consistent in the further steps) -
Add the required Custom fields in the form called
new_form -
Use the
form_nameparameter in the callbackloadExtendedUser. 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' });