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

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

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

results in

"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?


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

delete user.user_metadata.full_phone;

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);


1 Like

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

1 Like

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