Solved Register a hook but lose another hook

  • Okay, so I'm experiencing something weird here.
    First thing first, my repo:

    I got 2 hooks in my plugin.json:

    "hook": "filter:privileges.topics.get", "method": "onGetTopicPrivSettings",
    "hook": "static:api.routes", "method": "addRoutes"

    These hooks are served by /lib/theme.js.
    The problem is:

    • If I register static:api.routes, the hook filter:privileges.topics.get will not register.
    • If I don't register static:api.routes (aka remove from plugin.json), filter:privileges.topics.get will be registered.

    Can someone please tell me what's going on? Why can't I register both static:api.routes and filter:privileges.topics.get?

  • Each hook definition needs to be in a separate object, right now they're all in the same one so only the last is used.

    You need to have something like:

    { "hook": ..., "method": ... },
    { "hook": ..., "method": ... },

  • Thank you so much. And I spent my afternoon debugging this, feeling so stupid right now 😄

Suggested Topics

| | | |