Trust level trigger is called before trust level is changed

I’m working on an additive trust level plugin that adds/deletes from a group depending on membership on a set of other groups (e.g., membership in paid and special also gets you into the paid-special group).

It’s very strange that TL promotions will trigger an :after_save event, but TL demotions do not trigger a :after_destroy event, but I’m working around that with DiscourseEvent.on(:user_promoted)

But that doesn’t work because the trigger gets called before the trust level is updated:

I submitted a PR: Trigger tl event after tl update by pfaffman · Pull Request #205 · pfaffman/discourse · GitHub

1 Like