Hide features for non-admin users through plugin


(ginger man) #1

tldr: I would like to hide certain features in the page & api backend for non-admin users.

For example,
I would like to show the list of liked users only for admin users and not for everyone. The count can be seen by everyone but not the list of users.

Of course this is just an example for my specific need. I am sure this feature will not enter in the core but how could I implement this as a plugin ? I would be interested to know about the api overrides (especially) & UI overrides through plugins.


(Rafael dos Santos Silva) #2

I suggest reading the wonderful series on plugins by @eviltrout, it starts here:

After read some official plugins on Discourse github page.

Then go trough some plugins on the #plugin category and dig trough their codebase.


(ginger man) #3

Thanks @Falco… Just want to quickly check if plugins can be used to control features in API as well ?


(Rafael dos Santos Silva) #4

You can monkeypatch classes so yes. Some stuff is easier than others, tough.


(cpradio) #5

Though I think this is simply overriding a widget, which shouldn’t be too bad to do.


(Rafael dos Santos Silva) #6

Yeah, but if he wants to block this trough API too, it’s more works because the post_actions is used for more stuff. Doable, but a little more work.