# Removing user metadata property doesn't function in pre user registration action

**URL:** <https://community.auth0.com/t/removing-user-metadata-property-doesnt-function-in-pre-user-registration-action/96036>\
**Category:** Get Help\
**Tags:** user-profile, user-management\
**Created:** [December 8, 2022, 3:43pm UTC](https://community.auth0.com/t/removing-user-metadata-property-doesnt-function-in-pre-user-registration-action/96036 "2022-12-08T15:43:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![richard5](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/richard5/32/13599_2.png) [@richard5](https://community.auth0.com/u/richard5)\
**Post date:** [December 8, 2022, 3:43pm UTC](https://community.auth0.com/t/removing-user-metadata-property-doesnt-function-in-pre-user-registration-action/96036/1 "2022-12-08T15:43:48Z")

</div>

The documentation for Pre User Registration actions states that

> _@param_ `value` — The value of the metadata property. This may be set to `null` to remove the metadata property.

However in practice setting a value of null does not remove the property, it sets it to null

```auto
api.user.setUserMetadata("full_phone", null);

```

results in

```auto
"user_metadata": {
	"first_name": "Test",
	"last_name": "User",
	"full_phone": null
}

```

I have tested this on both nodejs16 and 18 runtimes and found the same result.  
Is there a way to REMOVE the property in a pre user registration action?  
If not will this be supported?

Thanks

n.b. the required behaviour can be achieved with a Pre Reg Hook like so

```auto
delete user.user_metadata.full_phone;

```

---

<div class="post-metadata">

**Author:** ![lihua.zhang](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/lihua.zhang/32/39683_2.png) [@lihua.zhang](https://community.auth0.com/u/lihua.zhang)\
**Post date:** [December 9, 2022, 4:56pm UTC](https://community.auth0.com/t/removing-user-metadata-property-doesnt-function-in-pre-user-registration-action/96036/4 "2022-12-09T16:56:12Z")

</div>

Hi @richard5 ,

This is a known issue that is currently in the Engineering team’s backlog. The workaround is to set the attribute values to `undefined` instead of setting them to `null` in the pre-user-registration action. This will remove these properties from the user metadata.

`api.user.setUserMetadata('attribute_name', undefined);`

Thanks!

---

<div class="post-metadata">

**Author:** ![richard5](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/richard5/32/13599_2.png) [@richard5](https://community.auth0.com/u/richard5)\
**Post date:** [December 12, 2022, 9:38am UTC](https://community.auth0.com/t/removing-user-metadata-property-doesnt-function-in-pre-user-registration-action/96036/5 "2022-12-12T09:38:02Z")

</div>

Thanks @lihua.zhang setting it to undefined does remove the property

I’ve submitted feedback that this should be updated on the [pre registration flow documentation here](https://auth0.com/docs/customize/actions/flows-and-triggers/pre-user-registration-flow/api-object)

---

<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:** [December 26, 2022, 9:38am UTC](https://community.auth0.com/t/removing-user-metadata-property-doesnt-function-in-pre-user-registration-action/96036/6 "2022-12-26T09:38:05Z")

</div>

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