Hide features for non-admin users through plugin

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.

我建议阅读 @eviltrout 撰写的精彩插件系列文章,从这里开始:

阅读后,可以看看 Discourse GitHub 页面 上的一些官方插件。

然后,去 Customization > Plugin 分类下浏览一些插件,并深入研究它们的代码库。

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

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

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

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.