# Managing user data with the {{user.email}} variable

The `{{user.email}}` variable can be used in cases when you need to load data that belongs to a particular user or manage component visibility based on specific user roles. Check out the sections below to review these cases.

## Loading data belonging to the current user

Let's say you want users to have access only to the data specific to them (for example, about their orders) based on their email. This is how you can do that:point\_down:

1. First, create an action that will load the data of the current user.\
   It can be an **SQL Query** action step referencing the current user email:

```sql
select * from users where users.email="user.email";
```

2. Turn on the **Transform result** toggle and specify there `return {{data[0]}}` , as the action will return an array of users with only a single item in it.

<figure><img src="/files/XKbtkLnj3uZXFz0WSY2b" alt=""><figcaption></figcaption></figure>

3. Now, after loading your user, you can fill their information (for example, about their orders) using a **Load Table** action step.
4. In the **Filters** section of the *Load Table* action, configure a filter that will reference the action from step 1 holding additional information about the current user:

`id = {{actions.getUser.id}}`

<figure><img src="/files/BPy7zszryXMd5OHz9DgD" alt=""><figcaption></figcaption></figure>

That's it! Now when different users login into the application, they will see only their orders' data.

## Managing component visibility based on the user's role

Let's say you want to make certain components visible only to specific user roles - you can do that using the **Condition** setting of a component. We'll show how you can do that reviewing the use case of a *Text input* component visible only to the *Admin*.

In our case, we want the Admins of the workspace to be able to perform the search by customers and look for specific customer records. For this purpose, we've added a *Text input* component to the working area.&#x20;

Next, to set component visibility we've specified the following condition in the component's *Condition* setting:

```javascript
{{user.role}} === 'admin'
```

And that's it! Now, any user with the Admin role will be able to see the customer search input, while for regular users the component will be hidden.

<figure><img src="/files/TzCUM2ZlriWRUXzVAFSs" alt=""><figcaption></figcaption></figure>


---

# 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.uibakery.io/how-tos/data/load-user-specific-data-with-user.email-variable.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.
