# Plugin development: site settings "enabled" checkbox not working

**URL:** https://meta.discourse.org/t/plugin-development-site-settings-enabled-checkbox-not-working/65460
**Category:** Development
**Created:** [7월 2, 2017, 10:37오전 UTC](https://meta.discourse.org/t/plugin-development-site-settings-enabled-checkbox-not-working/65460 "2017-07-02T10:37:09Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![jack2](https://avatars.discourse-cdn.com/v4/letter/j/ac91a4/32.png) [@jack2](https://meta.discourse.org/u/jack2)
#### Post date: [7월 2, 2017, 10:37오전 UTC](https://meta.discourse.org/t/plugin-development-site-settings-enabled-checkbox-not-working/65460/1 "2017-07-02T10:37:09Z")

</div>

I declared a `myplugin_enabled` site setting in `config/settings.yml`, `config/locales/server.en.yml` and `plugin.rb` (as described [here](https://meta.discourse.org/t/beginners-guide-to-creating-discourse-plugins-part-3-custom-settings/31115)),.  
However, I’ve recently discovered that unchecking the box doesn’t disable my plugin. The plugin is loaded - and works correctly, including accessing other site settings - whatever the checkbox state.  
Any hint?

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [7월 2, 2017, 11:52오전 UTC](https://meta.discourse.org/t/plugin-development-site-settings-enabled-checkbox-not-working/65460/2 "2017-07-02T11:52:45Z")

</div>

That isn’t how that setting is meant to work. It is meant for you to disable your plugins behavior (in code) . Your plugin still gets loaded.

---

<div class="post-metadata">

### Author: ![jack2](https://avatars.discourse-cdn.com/v4/letter/j/ac91a4/32.png) [@jack2](https://meta.discourse.org/u/jack2)
#### Post date: [7월 2, 2017, 12:18오후 UTC](https://meta.discourse.org/t/plugin-development-site-settings-enabled-checkbox-not-working/65460/3 "2017-07-02T12:18:29Z")

</div>

Thanks @cpradio, that helps a lot.  
Maybe this could be clarified in the @eviltrout’s page I mentioned earlier.  
I guess the `enabled_site_setting :myplugin_enabled` line relates to “multisite setup”, as stated [here](https://meta.discourse.org/t/loading-our-sitesetting-properties-before-plugin-loads/45572/2), but at this stage I have no idea what it is 🙂

---

<div class="post-metadata">

### Author: ![leo.proctor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leo.proctor/32/216158_2.png) [@leo.proctor](https://meta.discourse.org/u/leo.proctor)
#### Post date: [1월 28, 2018, 9:46오전 UTC](https://meta.discourse.org/t/plugin-development-site-settings-enabled-checkbox-not-working/65460/4 "2018-01-28T09:46:33Z")

</div>

I face similar issue.

```
enabled_site_setting :myplugin_enabled
after_initialize do
  ::Topic.class_eval do
    after_commit do
      #myplugin code
    end
end

```

No matter if `myplugin_enabled` is true/false, myplugin code is executed. I don’t see any use for `enabled_site_setting` either. Can anyone explain what exactly it is? How can I enable/disable myplugin code based on myplugin\_enabled value?

---

<div class="post-metadata">

### Author: ![michaeld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/michaeld/32/1594_2.png) [@michaeld](https://meta.discourse.org/u/michaeld)
#### Post date: [1월 28, 2018, 9:52오전 UTC](https://meta.discourse.org/t/plugin-development-site-settings-enabled-checkbox-not-working/65460/5 "2018-01-28T09:52:09Z")

</div>

Use `if SiteSetting.myplugin_enabled` to check for that.

---

<div class="post-metadata">

### Author: ![leo.proctor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leo.proctor/32/216158_2.png) [@leo.proctor](https://meta.discourse.org/u/leo.proctor)
#### Post date: [1월 28, 2018, 9:59오전 UTC](https://meta.discourse.org/t/plugin-development-site-settings-enabled-checkbox-not-working/65460/6 "2018-01-28T09:59:06Z")

</div>

Yeah, that is how I’m currently doing it. But I don’t see any use for `enabled_site_setting: myplugin_enabled`. It doesn’t make any difference if I keep/remove it. I’m trying to understand it. As explained [here](https://meta.discourse.org/t/beginners-guide-to-creating-discourse-plugins-part-3-custom-settings/31115), it turns our features on and off 😕

---

<div class="post-metadata">

### Author: ![michaeld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/michaeld/32/1594_2.png) [@michaeld](https://meta.discourse.org/u/michaeld)
#### Post date: [1월 28, 2018, 8:12오후 UTC](https://meta.discourse.org/t/plugin-development-site-settings-enabled-checkbox-not-working/65460/7 "2018-01-28T20:12:00Z")

</div>

It’s an on/off switch with the special property that it shows up on the Admin / Plugins screen.

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [1월 28, 2018, 9:42오후 UTC](https://meta.discourse.org/t/plugin-development-site-settings-enabled-checkbox-not-working/65460/8 "2018-01-28T21:42:51Z")

</div>

Discourse doesn’t actually have a clean way to undo the effects of a loaded plugin, so it trusts the plugin code to be checking that setting instead.
