# Update user profile on sign-up using Hooks

Using [Hooks](/customization/events-hooks/denohooks.md) you can put **extra information** into the user profile's [custom attributes](/integration/user-profiles/profile-custom-attributes.md) programmatically. This is useful for [Profile Enrichment](https://www.authgear.com/post/how-profile-enrichment-can-boost-your-product) where making your current customer data better by adding more details from outside sources.

Here are easy steps to achieve this:

**Step 1.** Make sure that you have an Authgear account. If you don't have one, you can [create it for free](https://accounts.portal.authgear.com/signup) on the Authgear website. Start by logging into your [Authgear dashboard](https://portal.authgear.com/).

**Step 2.** Go to **User Profile** → **Custom Attributes** page.

**Step 3.** Add 3 new attributes there, namely *city*, *name*, and *timezone*:

<figure><img src="https://uploads-ssl.webflow.com/60658b47b03f0c77e8c14884/64c3b36a761d2d11e1c5ea89_Untitled%20(5).png" alt=""><figcaption></figcaption></figure>

**Step 4**. Navigate to your Authgear Dashboard's **Advanced**->**Hooks** section.

**Step 5. Add** a new **Blocking Event**.

**Step 6.** Choose the Block Hook **Type** as the *TypeScript* and set the Event option to *User* *pre-create*. You will write a new Typescript function from scratch.

**Step 7.** Click on **Edit Script** under the **Config** option.

**Step 8.** Write a function logic for how you integrate any external API to populate custom attributes into the editor. For example.

```typescript
		
export default async function(e: EventUserPreCreate): Promise
			 {
  // API Key for IP Geolocation
  const apiKey = 'MY_API_KEY';
  // Any random IP address
	const ipAddress = '8.8.8.8' 

  // Fetch data from the IP Geolocation API
  const response = await fetch(`https://api.ipgeolocation.io/ipgeo?apiKey=${apiKey}&ip=${ipAddress}`);
  const data = await response.json();

return {
    is_allowed: true,
    mutations:{
      user: {
          custom_attributes: {
            "city": data.city, 
            "country": data.country_name,
            "timezone": data.time_zone.name
        }
      }
    },
  };
}
```

**Step 9.** Now if you navigate to **User Management** and **Add** a new user.

<figure><img src="https://uploads-ssl.webflow.com/60658b47b03f0c77e8c14884/64c3b456e2d961a288183a98_Untitled%20(6).png" alt=""><figcaption></figcaption></figure>

**Step 10.** After the user is created, you should able to see custom attributes values have been updated for the user:

<figure><img src="https://uploads-ssl.webflow.com/60658b47b03f0c77e8c14884/64c3b46e2482cbed9e3a37af_Untitled%20(7).png" alt=""><figcaption></figcaption></figure>

#### Next steps

Once you learned how to update user profiles, now you can discover different ways of [accessing user profiles](/integration/user-profiles/access-user-profiles.md) in Authgear.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.authgear.com/integration/user-profiles/update-user-profile-on-sign-up-using-hooks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
