# Display username when login in banner

**URL:** https://meta.discourse.org/t/display-username-when-login-in-banner/83024
**Category:** Development
**Created:** [March 14, 2018, 10:57pm UTC](https://meta.discourse.org/t/display-username-when-login-in-banner/83024 "2018-03-14T22:57:11Z")
**Posts on this page:** 1
**Showing post:** 10

<div class="post-metadata">

### Author: ![tshenry](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tshenry/32/119495_2.png) [@tshenry](https://meta.discourse.org/u/tshenry)
#### Post date: [March 15, 2018, 9:15pm UTC](https://meta.discourse.org/t/display-username-when-login-in-banner/83024/10 "2018-03-15T21:15:59Z")

</div>

It looks like you copied the wrong code. This is what you want to add to `</head>` tab:

```plaintext
<script type="text/discourse-plugin" version="0.8.18">
    api.onPageChange(() => {
        if(api.getCurrentUser() != null) {
            $("#logged-in-user").text(" " + api.getCurrentUser().name.split(' ')[0]);
        }
    });
</script>

```

And place this in the After Header tab where appropriate:

```plaintext
<h2 class="x-title">Hey<span id="logged-in-user"></span>! Bienvenue dans ta nouvelle communauté</h2>

```

---

_[View the full topic](https://meta.discourse.org/t/display-username-when-login-in-banner/83024)._
