# Como acessar campos personalizados em um componente de tema?

**URL:** https://meta.discourse.org/t/how-do-i-access-custom-fields-in-a-theme-component/134701
**Category:** Development
**Created:** [29 Novembro , 2019 11:23 UTC](https://meta.discourse.org/t/how-do-i-access-custom-fields-in-a-theme-component/134701 "2019-11-29T11:23:20Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [29 Novembro , 2019 15:21 UTC](https://meta.discourse.org/t/how-do-i-access-custom-fields-in-a-theme-component/134701/2 "2019-11-29T15:21:18Z")

</div>

Você pode tentar algo assim:

```html
<script type="text/discourse-plugin" version="0.8.27">
let currentUser = api.getCurrentUser();

if (currentUser) {
        api.container.lookup('store:main').find('user', currentUser.username).then((user) => {
        console.log('user', user.user_fields);
    });
}
</script>

```

Consulte [Usando a PluginAPI em Personalizações do Site](https://meta.discourse.org/t/using-the-pluginapi-in-site-customizations/41281) para detalhes sobre o tipo de script `"text/discourse-plugin"`.

---

_[View the full topic](https://meta.discourse.org/t/how-do-i-access-custom-fields-in-a-theme-component/134701)._
