# Storing given\_name, family\_name in root

**URL:** <https://community.auth0.com/t/storing-given-name-family-name-in-root/43976>\
**Category:** Get Help\
**Tags:** additionalsignupfiel\
**Created:** [June 2, 2020, 4:51pm UTC](https://community.auth0.com/t/storing-given-name-family-name-in-root/43976 "2020-06-02T16:51:10Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![brianvallelunga](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/brianvallelunga/32/12851_2.png) [@brianvallelunga](https://community.auth0.com/u/brianvallelunga)\
**Post date:** [June 2, 2020, 4:51pm UTC](https://community.auth0.com/t/storing-given-name-family-name-in-root/43976/1 "2020-06-02T16:51:10Z")

</div>

I’m trying to collect and store given\_name and family\_name on the sign-up screen. My configuration is below and successfully causes the fields to show:

```
      additionalSignUpFields: [
          {
            name: "given_name",
            placeholder: "first name",
            storage: "root"
          },
          {
            name: "family_name",
            placeholder: "last name",
            storage: "root"
          }]

```

However, when a user is created, the data is saved in the user\_metadata area instead of the root, which I have clearly specified according to the docs ([Lock Configuration Options - Auth0 Docs](https://auth0.com/docs/libraries/lock/v11/configuration#additionalsignupfields-array-)). What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![karen1](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/karen1/32/18279_2.png) [@karen1](https://community.auth0.com/u/karen1)\
**Post date:** [June 5, 2020, 3:59pm UTC](https://community.auth0.com/t/storing-given-name-family-name-in-root/43976/2 "2020-06-05T15:59:04Z")

</div>

Good morning,

The additional signup fields will always be stored in the metadata, regardless how you name them.

You will need to assign them to the user’s standard [claims](https://auth0.com/docs/api-auth/tutorials/adoption/scope-custom-claims?_ga=2.56208354.814248007.1591018036-637531102.1582645546#custom-claims) via [Rule](https://auth0.com/docs/rules).

---

<div class="post-metadata">

**Author:** ![brianvallelunga](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/brianvallelunga/32/12851_2.png) [@brianvallelunga](https://community.auth0.com/u/brianvallelunga)\
**Post date:** [June 5, 2020, 4:19pm UTC](https://community.auth0.com/t/storing-given-name-family-name-in-root/43976/3 "2020-06-05T16:19:03Z")

</div>

Is the documentation just wrong then? The docs are very clear that `given_name` and `family_name` can be stored in the root here:

[https://auth0.com/docs/libraries/lock/v11/configuration#additionalsignupfields-array-](https://auth0.com/docs/libraries/lock/v11/configuration?&_ga=2.186039787.397416168.1591108647-458554477.1591108647#additionalsignupfields-array-)

> If you want to save the value of the attribute in the root of your profile, use `storage: 'root'` . Only a subset of values can be stored this way. The list of attributes that can be added to your root profile is [here](https://auth0.com/docs/api/management/v2#!/Users/patch_users_by_id). By default, every additional sign up field is stored inside the user\_metadata object.

---

<div class="post-metadata">

**Author:** ![as2003](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/as2003/32/26100_2.png) [@as2003](https://community.auth0.com/u/as2003)\
**Post date:** [December 8, 2020, 11:45am UTC](https://community.auth0.com/t/storing-given-name-family-name-in-root/43976/4 "2020-12-08T11:45:33Z")

</div>

I’m also having this issue. I literally copied the example from [Lock Configuration Options](https://auth0.com/docs/libraries/lock/lock-configuration#additionalsignupfields-array-)

i.e.

```
var options = {
  additionalSignUpFields: [{
    name: "name",
    storage: "root"
  }]
};

```

…and `name` is still appearing in `user_metadata` only.

Please confirm if the documentation is wrong, or if this is a bug.

---

<div class="post-metadata">

**Author:** ![andreev.artem](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/andreev.artem/32/7041_2.png) [@andreev.artem](https://community.auth0.com/u/andreev.artem)\
**Post date:** [April 19, 2021, 3:53pm UTC](https://community.auth0.com/t/storing-given-name-family-name-in-root/43976/5 "2021-04-19T15:53:46Z")

</div>

I also have the same issue - documentation says we can store these fields in the root, but “storage: ‘root’” just doesn’t work.

---

<div class="post-metadata">

**Author:** ![FullStackFool](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/fullstackfool/32/25823_2.png) [@FullStackFool](https://community.auth0.com/u/FullStackFool)\
**Post date:** [August 2, 2021, 8:33am UTC](https://community.auth0.com/t/storing-given-name-family-name-in-root/43976/6 "2021-08-02T08:33:34Z")

</div>

Been battling this for weeks, this is what I’ve come up with:

- `additionalSignUpFields` will always store in the `user_metadata`, even if the name of the field matches a standardised root claim.

- You CAN add these claims in a Post-Registration Action, using something like the example below, but the Post-Registration Actions are run **asynchonously** - so you have zero guarantee that the call to the management API will complete before the auth server redirects you back to your app.

```auto
exports.onExecutePostUserRegistration = async (event) => {
    const { clientDomain, clientID, clientSecret } = event.secrets;
    const ManagementClient = require('auth0').ManagementClient;
    var management = new ManagementClient({
        domain: clientDomain,
        clientId: clientID,
        clientSecret: clientSecret,
    });

    management.updateUser(
        { id : event.user.user_id}, 
        { "given_name": event.user.user_metadata.first_name, "family_name": event.user.user_metadata.last_name}
    );
}

```

- A Pre-Registration Action runs synchronously but does not allow you to modify the root user claims, only metadata. You also cannot use the method above because there is no user stored at this stage (you have no ID).

- You **can** create a custom login form that does allow you to store whatever root fields you want at registration, but you have to use a custom template, which loses a lot of the power of Universal/Lock. Things like adding social login and MFA become more complex to add.

- You could use `additionalSignUpFields`, add the custom fields to the metadata, add the metadata to the idToken via a Post-Login Action, then in your app collapse all the profile info down to one flat object for local use 🤷‍♂️

@karen1 (gonna tag @konrad.sopala too as he’s a forum legend) there is a hell of a lot of people on the forum begging for an easy solution to this, for quite a while now. It is such a standard thing to ask for Given & Family Name in a signup form. Several solutions:

- Make Post-Registration Hook synchronous.
- Parse `additionalSignUpFields` for root claims and add only those to the root profile.
- Add another option to the Lock config eg: `rootSignUpFields` that only allows things like name, DOB, etc.
- Allow editing of the user object (beyond metadata) in a Pre-Registration Action.

But we really do need a solution. The point of the service is to simplify authentication and signup - if we have to backflip through flaming hoops to add first & last name to a user at registration then it’s kinda defeating the purpose…

---

<div class="post-metadata">

**Author:** ![dudumonteiro](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dudumonteiro/32/35891_2.png) [@dudumonteiro](https://community.auth0.com/u/dudumonteiro)\
**Post date:** [September 24, 2023, 3:44pm UTC](https://community.auth0.com/t/storing-given-name-family-name-in-root/43976/7 "2023-09-24T15:44:12Z")

</div>

Do we have a solution for this?
