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

How to collect first and last names of users outside of the registration flow?

The Identity Management registration form allows you to collect users' first and last names (and even make them mandatory fields during the registration) out of the box.

In case you have added these fields to the Piano ID register page template or marked them as mandatory at any later point since you've started collecting user registrations, you still have the option to ask users who lack this data to provide this information via a Custom form and backfill it in their user profiles.

It is not possible to collect the first and last names directly in registration forms after the user has already created an account.

The first option is to use a Custom form to get values for these 2 names through Custom fields, but the first and last names wouldn't be considered to be the same field as the ones which are filled during registration. Basically, you will collect data in 2 custom fields called 'first name' and 'last name' and then use the Piano API to update the first and last names on the user's profile. You can use the following endpoint to update a user's first and last names with the values from the custom fields: https://docs.piano.io/api?endpoint=post~2F~2Fpublisher~2Fuser~2Fupdate

The custom field values can be retrieved for example from this endpoint: https://docs.piano.io/api?endpoint=post~2F~2Fpublisher~2Fuser~2Fget or via webhooks.

If you'd like to target those users who don't have first and last names via a Composer Experience, you can do so by the below workaround:

1. Detecting if the user has provided their first and last name:

We suggest doing this in the Login success callback, you can do it every time users log in. In this callback, you can check if the user filled in the first name and last name using tp.pianoId.getUser(). You can then set a specific cookie for these users (must be prefixed with _pc_ so that it will be recognized by Composer).

For example, using:

document.cookie = "_pc_firstLastName=false"

2. Detecting these users in Composer:

After you set the cookie, you can use the Custom cookie segmentation.

3.a) Asking users to fill in a Custom form:

You can show users with the cookie a custom form, in which they would provide the values for their names in two custom fields, which you can access and ingest via API to fill in the user's profile with first and last names as described above.

3.b) Asking users to fill in their names in My Account:

You can redirect users to My Account to fill in their names or show them a template that would ask them to do so and link to My Account.

Last updated: