Discourse.SiteSettings is Undefined in Plugin Initializer code

When I attempt to do something like the following:

if (!Discourse.SiteSetting.my_plugin_enabled) {
    // code here
}

My page won’t load & I get an error in the dev console saying Cannot read property 'my_plugin_enabled' of undefined.


My plugin.rb includes enabled_site_setting :my_plugin_enabled, and my settings.yml includes my_plugin_enabled set to true for default & the client

You can access the SiteSetting object like this:

4 Likes

Thank you very much!