# User Management

## How to get user data and use it across the application?

* [ ] [Save user data to the global variable](https://docs.metaproprotocol.com/developer-documentation/user-onboarding-and-authorization#getting-user-data-from-expressions) to make it usable across the application
* [ ] Use it in the components that need it

<figure><img src="https://2351247042-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9QQIPimQeOGE3C1HbWxf%2Fuploads%2F5hYMTuzpnMqwZm3gFhk2%2Fimage.png?alt=media&#x26;token=cf547470-8893-420c-90a6-b3aa699089a3" alt=""><figcaption></figcaption></figure>

## How to update the username?

* [ ] Get a username from the input
* [ ] [Use the **Update Username**](#updating-username) action to change it
* [ ] Save the updated username in the user data global variable

<figure><img src="https://2351247042-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9QQIPimQeOGE3C1HbWxf%2Fuploads%2FG2HhFuF7eqrrIXy1McwR%2Fimage.png?alt=media&#x26;token=256ac19c-d781-4b23-b2ea-8dd430102038" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2351247042-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9QQIPimQeOGE3C1HbWxf%2Fuploads%2FQpbpHTZQdr90C2mFKQVD%2Fimage.png?alt=media&#x26;token=d07fc39b-4a32-4d00-8325-d85203e8a992" alt="" width="375"><figcaption></figcaption></figure>

## How to update the user avatar?&#x20;

1. Get an avatar link from the input
2. [Use the Update Avatar action](#update-avatar) to change it
3. Save the updated avatar in the user data global variable

## Updating username&#x20;

The **Update Username** action is used to update the username for the logged-in user. If a new username is provided, it updates the user's profile with the new name; otherwise, it removes the username field. It sends a `PATCH` request to update the user's personal details using the `x-account-userid` and `Authorization` headers, which contain the user's ID and access token.

Once the username is successfully updated, the **On Username Updated** condition is triggered. The new username can be retrieved by calling the **Get Username** expression from the plugin.

## Update avatar

The **Update Avatar** is used to update the avatar for the logged-in user. If a new avatar URL is provided, it updates the user's profile with the new avatar; otherwise, it removes the avatar field. It sends a `PATCH` request to update the user's personal details using the `x-account-userid` and `Authorization` headers, which contain the user's ID and access token.

Upon successful avatar update, the **On Avatar Updated** condition is triggered. The new avatar URL can be retrieved by calling the **Get Avatar** expression from the plugin.
