# Display username when login in banner

**URL:** <https://meta.discourse.org/t/display-username-when-login-in-banner/83024>\
**Category:** Development\
**Created:** [3월 14, 2018, 10:57오후 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:** 12

<div class="post-metadata">

**Author:** ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)\
**Post date:** [3월 16, 2018, 9:31오전 UTC](https://meta.discourse.org/t/display-username-when-login-in-banner/83024/12 "2018-03-16T09:31:34Z")

</div>

Thanks for this, love it!

Have slightly modified the script to include the ‘Hey!’ in the script, thereby getting around the issue of showing the ‘Hey!’ if name is blank:

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

```

I’ve used this shorter greeting in a more discrete spot at the side of my site banners, just above the avatar.

---

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