# 管理者のみが使用できるテーマを作成する方法

**URL:** <https://meta.discourse.org/t/how-to-create-a-theme-which-only-administrators-can-use/268500>\
**Category:** Development\
**Created:** [2023 年 6 月 15 日午後 5:46 UTC](https://meta.discourse.org/t/how-to-create-a-theme-which-only-administrators-can-use/268500 "2023-06-15T17:46:11Z")\
**Posts on this page:** 1\
**Showing post:** 14

<div class="post-metadata">

**Author:** ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)\
**Post date:** [2023 年 6 月 16 日午前 11:36 UTC](https://meta.discourse.org/t/how-to-create-a-theme-which-only-administrators-can-use/268500/14 "2023-06-16T11:36:07Z")

</div>

ここにいる皆さんが言っていることのほとんどに同意します。

もし本当にCSSの方法で行きたいなら、管理者以外にのみCSSの変更を適用する方法は次のとおりです。

テーマの「Head」タブに次のように記述します。

```js
    <script type="text/discourse-plugin" version="1.4.0">
        let currentUser = api.getCurrentUser();
        if (currentUser.admin == true) {
             document.querySelector("body").classList.add("is-admin");
        }
    </script>

```

すべてのCSSルールを `body:not(.is-admin) {` （あなたのCSS） `}` で囲みます。たとえば次のようになります。

```css
body:not(.is-admin) {
    #main {
        background: pink;
    }
}

```

私の例では、ピンクの背景は管理者以外のすべての人に適用されます。

---

_[View the full topic](https://meta.discourse.org/t/how-to-create-a-theme-which-only-administrators-can-use/268500)._
