• Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
v3.5.2 Latest
Buy Hosting

Register a hook but lose another hook

Scheduled Pinned Locked Moved Solved Technical Support
3 Posts 2 Posters 221 Views
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    ducntq
    wrote on last edited by
    #1

    Okay, so I'm experiencing something weird here.
    First thing first, my repo: https://github.com/ducntq/nodebb-theme-devmonkee

    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?

    1 Reply Last reply
    0
  • PitaJP Offline
    PitaJP Offline
    PitaJ Global Moderator Plugin & Theme Dev
    wrote on last edited by
    #2

    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": ... },
    etc
    
    1 Reply Last reply
    0
  • D Offline
    D Offline
    ducntq
    wrote on last edited by
    #3

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

    1 Reply Last reply
    0

Copyright © 2023 NodeBB | Contributors
  • Login

  • Don't have an account? Register

  • Login or register to search.
Powered by NodeBB Contributors
  • First post
    Last post
0
  • Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development