What is the best way to provide per user plugin configuration

Background: I have dark mode for panel nearly done, but it’s quite basic/hacky, so I thought I’d turn it on only for myself in the panel, but I’m not sure how to set it up so every user had their own toggle to turn it on or off.

Config page which somehow checks user and some sort of datastore - that seems complicated.

Is there a system for per user configiguration for plugins?

What you could try:

  • use a config option in your plugin that determines if the plugin should do something or not.
  • Use a (toggle) field in your user blueprints where users can set if they want it or not
  • In your config, use the ready() option to query the current user setting and set this for your config option

so:

  1. read config.php for global pref
  2. read user bluprint/file for per user pref
  3. use ready() in config.php to set in memory pref to user’s if they don’t match

So in any case, I do have to add it manually to the user blueprint? There’s no in-built system for “this plugin needs these options from users”?

You should also be able to get the current user settings in your plugin.

Allright! I had hoped for some magical $kirby->configurable('boolean'), but this works as well :smiley:

No wait, I just realized a problem; if I want to share the plugin with the world, not only do the developer have to add the config to their user blueprints, but also it has to be specifically named, right?

So if you for instance wanted to use it, you’d download it and have to add “stupidDarkModeToggle” to your blueprints?

If you want to do it based on user settings, then yes, this setting would’ve to be added to each user blueprints. Not really a plug&play solution…

Damn, that’s not superuserfriendly. :confused:

I sort of hoped to be handwave the limitations with “turn it on only for yourself” :smiley:

Maybe with the janitor button