# Admin only button in header?

**URL:** https://meta.discourse.org/t/admin-only-button-in-header/98732
**Category:** Support
**Created:** [October 4, 2018, 4:01pm UTC](https://meta.discourse.org/t/admin-only-button-in-header/98732 "2018-10-04T16:01:03Z")
**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: [October 4, 2018, 9:37pm UTC](https://meta.discourse.org/t/admin-only-button-in-header/98732/2 "2018-10-04T21:37:13Z")

</div>

Discourse adds a `staff` class to the `body` tag when a staff user is viewing the site. If you are ok with the button being visible to admins and moderators, you could hide the button with CSS and then make it visible when the `staff` class is present.

If only having the button visible to admins is a requirement, you will need to use some javascript to determine that the user is an admin. The easiest approach to that would be to add an `admin` class to the body and then make the button visible when the `admin` class is present:

```plaintext
<script type="text/discourse-plugin" version="0.8.23">
let currentUser = api.getCurrentUser();
if (currentUser && currentUser.admin) {
    $('body').addClass('admin');
}
</script>

```

If hiding the button with CSS isn’t secure enough for your use case, you will need to do something a little more involved to insert the button with javascript.

---

_[View the full topic](https://meta.discourse.org/t/admin-only-button-in-header/98732)._
