# Post Registration Hook - User Properties Not Pulling In

**URL:** <https://community.auth0.com/t/post-registration-hook-user-properties-not-pulling-in/30914>\
**Category:** Get Help\
**Tags:** hooks\
**Created:** [September 16, 2019, 6:35am UTC](https://community.auth0.com/t/post-registration-hook-user-properties-not-pulling-in/30914 "2019-09-16T06:35:02Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![darren.tiplady](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/darren.tiplady/32/12951_2.png) [@darren.tiplady](https://community.auth0.com/u/darren.tiplady)\
**Post date:** [September 16, 2019, 6:35am UTC](https://community.auth0.com/t/post-registration-hook-user-properties-not-pulling-in/30914/1 "2019-09-16T06:35:03Z")

</div>

Hi,

We are currently using a post registration web-hook to do a bit of custom functionality.  
The JSON used when testing the web-hook through the interface looks like this

```
{
  "user": {
    "id": "abc123",
    "tenant": "my-tenant",
    "name":"Testing",
    "username": "user1",
    "email": "user1@foo.com",
    "emailVerified": true,
    "phoneNumber": "1-000-000-0000",
    "phoneNumberVerified": true,
    "user_metadata": {
      "hobby": "surfing"
    },
    "app_metadata": {
      "plan": "full"
    }
  },
  "context": {
    "requestLanguage": "en-us",
    "connection": {
      "id": "con_xxxxxxxxxxxxxxxx",
      "name": "Username-Password-Authentication",
      "tenant": "my-tenant"
    }
  }
}'

```

When printing out the user object i can see that the name property is set. However when creating a user using the /dbconnections/signup on the management API, setting any of the other use properties such as name, given\_name, nickname etc, these don’t pull through into the hook when i print out the user object.

It seems silly to have to set the name in the user\_metadata property to access it

Thanks

---

<div class="post-metadata">

**Author:** ![mathiasconradt](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mathiasconradt/32/12758_2.png) [@mathiasconradt](https://community.auth0.com/u/mathiasconradt)\
**Post date:** [September 16, 2019, 6:57am UTC](https://community.auth0.com/t/post-registration-hook-user-properties-not-pulling-in/30914/2 "2019-09-16T06:57:55Z")

</div>

Hi @darren.tiplady,

> when i print out the user object.

How do you print out the user? Is this in your client application, or via `console log` in the hook and checking the webtask realtime logs (asking cause the latter wouldn’t work in a post-reg hook due to asynchronisity)?

What’s the code of your hook?

---

<div class="post-metadata">

**Author:** ![darren.tiplady](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/darren.tiplady/32/12951_2.png) [@darren.tiplady](https://community.auth0.com/u/darren.tiplady)\
**Post date:** [September 16, 2019, 8:51am UTC](https://community.auth0.com/t/post-registration-hook-user-properties-not-pulling-in/30914/3 "2019-09-16T08:51:37Z")

</div>

Hi Mat,

The user is being printed out when i was testing the hook via the webtask realtime logs. Screenshot below.

 ![image](https://global.discourse-cdn.com/auth0/original/3X/3/4/346c1110ab71922072e544a48ee538f83c1444bd.png)

When testing from my application i let the code run through the management API’s endpoint

> /dbconnections/signup

I then checked the log of the web-hook to see what the user object is that was printed out was. As an example this is what was printed out .

![image](https://global.discourse-cdn.com/auth0/original/3X/d/4/d44d5c0ea4fd2c153e16ece49a01114bb06ee6fb.png)

Webhook below.

```
/**
@param {object} user - The user being created
@param {string} user.id - user id
@param {string} user.tenant - Auth0 tenant name
@param {string} user.username - user name
@param {string} user.email - email
@param {boolean} user.emailVerified - is e-mail verified?
@param {string} user.phoneNumber - phone number
@param {boolean} user.phoneNumberVerified - is phone number verified?
@param {object} user.user_metadata - user metadata
@param {object} user.app_metadata - application metadata
@param {object} context - Auth0 connection and other context info
@param {string} context.requestLanguage - language of the client agent
@param {object} context.connection - information about the Auth0 connection
@param {object} context.connection.id - connection id
@param {object} context.connection.name - connection name
@param {object} context.connection.tenant - connection tenant
@param {object} context.webtask - webtask context
@param {function} cb - function (error, response)
*/
module.exports = function (user, context, cb) {

    console.log('User: o%', user);
    
    // Constants
    const request = require('request-promise');
    const sgMail = require('@sendgrid/mail');
    const auth0verificationEmailUrl = 'https://lawyerly-internal.eu.auth0.com/api/v2/email-templates/verify_email';
    const sendGridApiKey = context.webtask.secrets['sendgrid-apikey'];
    const firmSignupClientId = context.webtask.secrets['firm-signup-client-id'];
    const firmSignupClientSecret = context.webtask.secrets['firm-signup-client-secret'];
    
    // Email Replacement Variables
    const displayName = user.user_metadata.firstname;
    const user_id = 'auth0|' + user.id;
    var verify_email_Template;
    
    // Auth0 Access Token
    var accessToken;
    
    // Auth0 Access Token Request Options
    var accessTokenOptions = {
        method: 'POST',
        url: 'https://lawyerly-internal.eu.auth0.com/oauth/token',
        form:{
          grant_type: 'client_credentials',
          client_id: firmSignupClientId,
          client_secret: firmSignupClientSecret,
          audience: 'https://lawyerly-internal.eu.auth0.com/api/v2/'
        },
        resolveWithFullResponse: true
    };
  
    // Main Request
    request(accessTokenOptions)
        .then(function onSuccess(response) {
            if (response.statusCode == 400)
                console.log('Invalid model received %o', response);
            if (response.statusCode == 200) {
                // Save the access token
                accessToken = JSON.parse(response.body);
            }
            
            // Auth0 Verification Email Settings
            var verifyEmailOptions = {
                method: 'GET',
                url: auth0verificationEmailUrl,
                headers: { 'Authorization': 'bearer ' + accessToken.access_token },
                resolveWithFullResponse: true
            };
            
            // Get the verification email template
            request(verifyEmailOptions)
                .then(function onSuccess(response) {
                    if (response.statusCode == 400)
                        console.log('Invalid model received %o', response);
                    if (response.statusCode == 200) {
                        verify_email_Template = response.body.replace(/user_id/g, user_id)
                            .replace('{{ user.app_metadata.displayName }}', displayName);
                        
                        // Parse Template to JSON
                        jsonVerificationTemplate = JSON.parse(verify_email_Template);
        
                        // Setup SendGrid Email
                        sgMail.setApiKey(sendGridApiKey);
                        const msg = {
                            to: user.email,
                            from: jsonVerificationTemplate.from,
                            subject: jsonVerificationTemplate.subject,
                            content: [
                                {
                                    type: 'text/html',
                                    value: jsonVerificationTemplate.body
                                }]
                        };
        
                        // Send mail
                        sgMail
                            .send(msg)
                            .then(() => {
                                console.log('Success SendGrid Mail Sent');
                            })
                            .catch(error => {
                                //Log friendly error
                                console.error(error.toString());
        
                                //Extract error msg
                                const { message, code, response } = error;
        
                                //Extract response msg
                                const { headers, body } = response;
                            });
                    }
        
                    // Ensure callback is called on each path
                        cb();
                    }).catch(function onError(err) {
                        console.error(error.toString());
                        cb();
                    });
            
            
            // Ensure callback is called on each path
            cb();
        }).catch(function onError(err) {
            console.error(error.toString());
            cb();
        });
};

```

---

<div class="post-metadata">

**Author:** ![lmuller18](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/lmuller18/32/16190_2.png) [@lmuller18](https://community.auth0.com/u/lmuller18)\
**Post date:** [September 19, 2019, 2:15am UTC](https://community.auth0.com/t/post-registration-hook-user-properties-not-pulling-in/30914/4 "2019-09-19T02:15:21Z")

</div>

To add to this, user.picture is also not available during the post-registration hook even though it is part of the normalized user profile.

---

<div class="post-metadata">

**Author:** ![calqulate](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/calqulate/32/19295_2.png) [@calqulate](https://community.auth0.com/u/calqulate)\
**Post date:** [March 19, 2020, 5:33pm UTC](https://community.auth0.com/t/post-registration-hook-user-properties-not-pulling-in/30914/5 "2020-03-19T17:33:41Z")

</div>

Any updates on this please? I’m facing the same problem.

---

<div class="post-metadata">

**Author:** ![kurtjosephabela](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/kurtjosephabela/32/20302_2.png) [@kurtjosephabela](https://community.auth0.com/u/kurtjosephabela)\
**Post date:** [April 6, 2020, 9:54am UTC](https://community.auth0.com/t/post-registration-hook-user-properties-not-pulling-in/30914/6 "2020-04-06T09:54:01Z")

</div>

Same problem here. Any updates…? It’s been a while now

---

<div class="post-metadata">

**Author:** ![william.axelsson](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/william.axelsson/32/13540_2.png) [@william.axelsson](https://community.auth0.com/u/william.axelsson)\
**Post date:** [July 2, 2021, 2:22pm UTC](https://community.auth0.com/t/post-registration-hook-user-properties-not-pulling-in/30914/7 "2021-07-02T14:22:35Z")

</div>

Any update on this? I want to customize login to have first/last name.  
Adding them like this gives me the option to use { user } = useAuth0() hook with user.given\_name  
additionalSignUpFields: [{  
name: “given\_name”,  
storage: “root”,  
placeholder: “enter your first name”,  
},  
{  
name: “family\_name”,  
storage: “root”,  
placeholder: “Enter your last name”  
}]

but with this I can’t do user.given\_name in my post registration hook.

and if I don’t add them to root and add them to user\_metadata I can’t get them with the user useAuth0 hook…

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [January 8, 2024, 10:42am UTC](https://community.auth0.com/t/post-registration-hook-user-properties-not-pulling-in/30914/8 "2024-01-08T10:42:55Z")

</div>

Hey there!

As this topic is related to Rules - Hooks - Actions and Rules & Hooks are being deprecated soon I’m excited to let you know about our next [Ask me Anything session in the Forum on Thursday, January 18 with the Rules, Hooks and Actions team](https://community.auth0.com/t/auth0-community-ask-me-anything-rules-hooks-and-why-actions-matter/124043) on Rules & Hooks and why Actions matter! Submit your questions in the thread above and our esteemed product experts will provide written answers on January 18. Find out more about Rules & Hooks and why Actions matter! Can’t wait to see you there!

[Learn more here!](https://community.auth0.com/t/auth0-community-ask-me-anything-rules-hooks-and-why-actions-matter/124043)
