Overriding user_guardian.rb in a plugin (no fork necessary!)

Here’s one where we’ve defined a method in the PostGuardian:

You could do something similar for the UserGuardian using the existing method name which should override it.

Simple solution (to get it working if not robustly):

Literally just write out the original method code and make your edit. Downside: if Discourse change the code your plugin could break the instance.

Advanced solution (more robust solution):

For extra points you might be able to use super to inherit the original method but that’s not guaranteed to work for reasons I shan’t elaborate here on but is best practice because then updates to that method in discourse will always be taken into account without you having to edit your plugin.

Discourse is a platform. It takes time to learn it. Just take it step by step.