# How to send a user attribute from Signup page to app metadata

**URL:** <https://community.auth0.com/t/how-to-send-a-user-attribute-from-signup-page-to-app-metadata/117073>\
**Category:** Get Help\
**Tags:** signup-prompt-new-experience, login-experience\
**Created:** [September 25, 2023, 2:06pm UTC](https://community.auth0.com/t/how-to-send-a-user-attribute-from-signup-page-to-app-metadata/117073 "2023-09-25T14:06:16Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aafreen\_Khan](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/aafreen_khan/32/49981_2.png) [@Aafreen\_Khan](https://community.auth0.com/u/Aafreen_Khan)\
**Post date:** [September 25, 2023, 2:06pm UTC](https://community.auth0.com/t/how-to-send-a-user-attribute-from-signup-page-to-app-metadata/117073/1 "2023-09-25T14:06:16Z")

</div>

Hi Community,  
@rueben.tiow @dan.woda @dawid.matuszczyk

I have a bit of questions as below regarding the user metadata and app metadata.

How can we make the user attributes in user profile not editable for the user?

Our understanding is that if we manage to place that attribute to the app-metadata then the user will not be able to edit it.  
Based upon my scenario I have added an additional field namely “usertype” which is a dropdown kind of fields to the signup page and i want it to be non editable to the user.

By default this is going to the user metadata(attributes in user metadata can be read/written by the user) which is just the opposite of our requirement. My question is  
How and where is user profile should we send this usertype field of the signup page so that it becomes not editable to the user?

Also please correct my understanding in case it isn’t.

Thanks and Regards,  
Aafreen Khan

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [September 25, 2023, 5:53pm UTC](https://community.auth0.com/t/how-to-send-a-user-attribute-from-signup-page-to-app-metadata/117073/3 "2023-09-25T17:53:16Z")

</div>

Hi @Aafreen_Khan,

The user’s attributes should not be editable by the users themselves unless you have a mechanism to allow them to update their own user attributes.

Can you please clarify how you are allowing the user to update their user attributes?

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![Aafreen\_Khan](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/aafreen_khan/32/49981_2.png) [@Aafreen\_Khan](https://community.auth0.com/u/Aafreen_Khan)\
**Post date:** [September 26, 2023, 8:06am UTC](https://community.auth0.com/t/how-to-send-a-user-attribute-from-signup-page-to-app-metadata/117073/4 "2023-09-26T08:06:13Z")

</div>

Hi @rueben.tiow

Thanks a lot for your prompt response.

Actually our project is still in the pre-implementation phase so we are exploring all the possibilities and vulnerabilities to be covered  
I am aware of the fact that for the user to be able to edit the user metadata attributes we have to rendered it to them through a form(not aware how exactly its done).  
Again the question stands is it alright/safe for the signup attributes to sit in the user metadata if we are not having any form/mechanism to render it to the user for editing?  
And given we don’t have a mechanism to edit user metadata attributes does there remains a need to transfer these attributes to app metadata?  
Actually i have a rule where i am able to send the selected signup field from the user metadata to the app metadata but i am not able to remove this attribute from the user metadata even after using delete operations on it.  
Here is the code below for the same:

```auto
 function usernameAttribute(user, context, callback) {
  
  if (!user.app_metadata.username) {
 
    user.app_metadata.username = user.app_metadata.username || user.username;
  }

  if (user.user_metadata && user.user_metadata.user_type) {
    
    user.app_metadata.user_type = user.user_metadata.user_type;

     user.user_metadata.user_type = null;
  }

  auth0.users
    .updateAppMetadata(user.user_id, user.app_metadata)
    .then(function () {

      callback(null, user, context);
    })
    .catch(function (err) {
      callback(err);
    });
}

```

Please let me know if it still requires some clarifications from my end.

Thanks and Regards,  
Aafreen Khan

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [October 2, 2023, 8:56pm UTC](https://community.auth0.com/t/how-to-send-a-user-attribute-from-signup-page-to-app-metadata/117073/5 "2023-10-02T20:56:46Z")

</div>

Hi @Aafreen_Khan,

Thanks for following up.

> [@Aafreen\_Khan](#):
>
> the question stands is it alright/safe for the signup attributes to sit in the user metadata if we are not having any form/mechanism to render it to the user for editing?

Yes, this is completely fine and encouraged.

> [@Aafreen\_Khan](#):
>
> And given we don’t have a mechanism to edit user metadata attributes does there remains a need to transfer these attributes to app metadata?

There is no need to duplicate the information in your app\_metadata if you have already added the signup attributes to the user metadata.

> [@Aafreen\_Khan](#):
>
> Actually i have a rule where i am able to send the selected signup field from the user metadata to the app metadata but i am not able to remove this attribute from the user metadata even after using delete operations on it.

You need to update the attribute with null using 'auth0.users.updateUserMetadata()` so that the data persists on the user’s profile.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![Aafreen\_Khan](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/aafreen_khan/32/49981_2.png) [@Aafreen\_Khan](https://community.auth0.com/u/Aafreen_Khan)\
**Post date:** [October 3, 2023, 7:25am UTC](https://community.auth0.com/t/how-to-send-a-user-attribute-from-signup-page-to-app-metadata/117073/6 "2023-10-03T07:25:11Z")

</div>

Hi @rueben.tiow

Thanks so much Rueben that’s a lot of help.  
Can you please also let me know how we can create that mechanism/form to render attributes in user metadata to be able to be edited by the users.  
If available, can you share the details and the auth0 doc link if any.

Thanks and Regards,  
Aafreen Khan

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [October 3, 2023, 5:21pm UTC](https://community.auth0.com/t/how-to-send-a-user-attribute-from-signup-page-to-app-metadata/117073/7 "2023-10-03T17:21:43Z")

</div>

Hi @Aafreen_Khan,

> [@Aafreen\_Khan](#):
>
> Can you please also let me know how we can create that mechanism/form to render attributes in user metadata to be able to be edited by the users.

For this, you will need to call the [Management API’s update a user endpoint](https://auth0.com/docs/api/management/v2/users/patch-users-by-id) when the user has made changes to their user metadata attributes.

Now, let me clarify that you have 2 options for getting an access token to call the Management API.

The first involves passing the `audience=(https://{tenant}.auth0.com/api/v2/)` parameter in the login request so the returning access token grants the user permission to update their user metadata. (Reference: [Call Your API Using the Authorization Code Flow](https://auth0.com/docs/authorization/flows/call-your-api-using-the-authorization-code-flow)).

The second involves making a [client credentials grant flow request](https://auth0.com/docs/get-started/authentication-and-authorization-flow/call-your-api-using-the-client-credentials-flow) to the Management API to get an access token.

Here are some additional resources:

- [Get Management API Access Tokens for Single-Page Applications](https://auth0.com/docs/secure/tokens/access-tokens/get-management-api-tokens-for-single-page-applications)
- [Get Management API Access Tokens for Production](https://auth0.com/docs/secure/tokens/access-tokens/get-management-api-access-tokens-for-production)

Please let me know if you have any questions.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [October 17, 2023, 5:22pm UTC](https://community.auth0.com/t/how-to-send-a-user-attribute-from-signup-page-to-app-metadata/117073/8 "2023-10-17T17:22:10Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
