# Pre User Registration adding of 'user\_metadata'

**URL:** <https://community.auth0.com/t/pre-user-registration-adding-of-user-metadata/63724>\
**Category:** Get Help\
**Tags:** pre-user-registratio, actions, login\
**Created:** [June 2, 2021, 11:36am UTC](https://community.auth0.com/t/pre-user-registration-adding-of-user-metadata/63724 "2021-06-02T11:36:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![killianoneachtain](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/killianoneachtain/32/13267_2.png) [@killianoneachtain](https://community.auth0.com/u/killianoneachtain)\
**Post date:** [June 2, 2021, 11:36am UTC](https://community.auth0.com/t/pre-user-registration-adding-of-user-metadata/63724/1 "2021-06-02T11:36:05Z")

</div>

Hi,  
I am trying to add ‘user\_metadata’ for each user on registration.  
I am currently allowing users to only register via Spotify. It is all working fine for me, except that i can’t create a default value in my ‘user\_metadata’.  
I have followed the example for it, but cannot get it to work.  
Do i need to pass values into it?  
exports.onExecutePreUserRegistration = async (event, api) =\> { /\*\*

- Handler that will be called during the execution of a PreUserRegistration flow.
- 
- @param {Event} event - Details about the context and user that is attempting to register.
- @param {PreUserRegistrationAPI} api - Interface whose methods can be used to change the behavior of the signup.  
\*/

module.exports = function (user, context, cb) {  
var response = {};  
// Add user or app metadata to the newly-created user  
response.user = {  
user\_metadata: { foo: ‘bar’ },  
app\_metadata: { vip: true, score: 7 }  
};  
response.user = user;  
cb(null, response);  
};  
};

---

<div class="post-metadata">

**Author:** ![killianoneachtain](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/killianoneachtain/32/13267_2.png) [@killianoneachtain](https://community.auth0.com/u/killianoneachtain)\
**Post date:** [June 2, 2021, 12:28pm UTC](https://community.auth0.com/t/pre-user-registration-adding-of-user-metadata/63724/2 "2021-06-02T12:28:57Z")

</div>

![Screenshot 2021-06-02 at 13.28.33](https://global.discourse-cdn.com/auth0/original/3X/d/e/de8e91b08776f1d62ad7f680bd29538389fbb3f2.png) ![Screenshot 2021-06-02 at 13.27.24](https://global.discourse-cdn.com/auth0/original/3X/9/d/9da48dd665648922f2bba4a7f46cec5b2f9b5a7b.png)

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [June 2, 2021, 2:10pm UTC](https://community.auth0.com/t/pre-user-registration-adding-of-user-metadata/63724/4 "2021-06-02T14:10:46Z")

</div>

Hi @killianoneachtain,

According to [the docs](https://auth0.com/docs/actions/triggers/pre-user-registration), the pre-user registration action trigger only runs for Database and Passwordless users, not for social connection users such as Spotify.

You can instead use a Post Login Action and check if it is the first login:

```auto
exports.onExecutePostLogin = async (event, api) => {
  if (event.stats.logins_count === 1) {
    api.user.setAppMetadata('vip', true);
  }
};

```

> **[Login Flow](https://auth0.com/docs/customize/actions/flows-and-triggers/login-flow)**
>
> Learn about the Actions Login Flow and the post-login Action trigger, which is executed after a user logs in and when a Refresh Token is requested.

---

<div class="post-metadata">

**Author:** ![killianoneachtain](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/killianoneachtain/32/13267_2.png) [@killianoneachtain](https://community.auth0.com/u/killianoneachtain)\
**Post date:** [June 2, 2021, 2:25pm UTC](https://community.auth0.com/t/pre-user-registration-adding-of-user-metadata/63724/5 "2021-06-02T14:25:39Z")

</div>

Thank you so much for that. I had tried to use Post-Registration Actions, but that wasn’t working either.  
It is working as hoped/expected now.  
Thanks again.

---

<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:** [June 17, 2021, 2:25pm UTC](https://community.auth0.com/t/pre-user-registration-adding-of-user-metadata/63724/6 "2021-06-17T14:25:52Z")

</div>

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