2014-04-26 17:06:21 -04:00
Available Hooks
2014-04-25 19:09:40 -04:00
=============
2014-04-28 16:18:13 -04:00
The following is a list of all hooks present in NodeBB. This list is intended to guide developers who are looking to write plugins for NodeBB. For more information, please consult :doc: `Writing Plugins for NodeBB <create>` .
2014-04-25 19:09:40 -04:00
There are two types of hooks, **filters** , and **actions** . Filters take an input (provided as a single argument), parse it in some way, and return the changed value. Actions take multiple inputs, and execute actions based on the inputs received. Actions do not return anything.
2014-04-26 17:06:21 -04:00
**Important** : This list is by no means exhaustive. Hooks are added on an as-needed basis (or if we can see a potential use case ahead of time), and all requests to add new hooks to NodeBB should be sent to us via the `issue tracker <https://github.com/designcreateplay/NodeBB/issues> `_ .
2014-04-25 19:09:40 -04:00
Filters
----------
`` filter:admin.header_build ``
^^^^^^^^^^^^^^^^^^^^^
Allows plugins to create new navigation links in the ACP
2014-04-26 17:06:21 -04:00
`` filter:post.save ``
2014-04-25 19:09:40 -04:00
^^^^^^^^^^^^^^^^^^^^^
**Argument(s)** : A post's content (markdown text)
Executed whenever a post is created or edited, but before it is saved into the database.
2014-04-26 17:06:21 -04:00
`` filter:post.get ``
2014-04-25 19:09:40 -04:00
^^^^^^^^^^^^^^^^^^^^^
**Argument(s)** : A post object (javascript Object)
Executed whenever a post is retrieved, but before being sent to the client.
2014-04-26 17:06:21 -04:00
`` filter:header.build ``
2014-04-25 19:09:40 -04:00
^^^^^^^^^^^^^^^^^^^^^
**Allows plugins to add new navigation links to NodeBB**
2014-05-19 14:00:29 -04:00
`` filter:register.build ``
^^^^^^^^^^^^^^^^^^^^^
**Argument(s)** :
- `req` the express request object (javascript Object)
- `res` the express response object (javascript Object)
- `data` the data passed to the template (javascript Object)
**Allows plugins to add new elements to the registration form. At the moment, the only one supported is `data.captcha`*
2014-04-26 17:06:21 -04:00
`` filter:post.parse ``
2014-04-25 19:09:40 -04:00
^^^^^^^^^^^^^^^^^^^^^
**Argument(s)** : A post or signature's raw text (String)
2014-04-26 17:06:21 -04:00
Executed when a post or signature needs to be parsed from raw text to HTML (for output to client). This is useful if you'd like to use a parser to prettify posts, such as `Markdown <http://daringfireball.net/projects/markdown/> `_ , or `BBCode <http://www.bbcode.org/> `_ .
2014-04-25 19:09:40 -04:00
2014-04-26 17:06:21 -04:00
`` filter:posts.custom_profile_info ``
2014-04-25 19:09:40 -04:00
^^^^^^^^^^^^^^^^^^^^^
**Allows plugins to add custom profile information in the topic view's author post block**
2014-04-26 17:06:21 -04:00
`` filter:register.check ``
2014-04-25 19:09:40 -04:00
^^^^^^^^^^^^^^^^^^^^^
2014-05-19 14:00:29 -04:00
**Argument(s)** :
- `req` the express request object (javascript Object)
- `res` the express response object (javascript Object)
- `userData` the user data parsed from the form
2014-04-25 19:09:40 -04:00
**Allows plugins to run checks on information and deny registration if necessary.**
2014-04-26 17:06:21 -04:00
`` filter:scripts.get ``
2014-04-25 19:09:40 -04:00
^^^^^^^^^^^^^^^^^^^^^
**Allows to add client-side JS to the header and queue up for minification on production**
2014-04-26 17:06:21 -04:00
`` filter:uploadImage ``
2014-04-25 19:09:40 -04:00
^^^^^^^^^^^^^^^^^^^^^
2014-04-26 17:06:21 -04:00
`` filter:uploadFile ``
2014-04-25 19:09:40 -04:00
^^^^^^^^^^^^^^^^^^^^^
2014-04-26 17:06:21 -04:00
`` filter:widgets.getAreas ``
2014-04-25 19:09:40 -04:00
^^^^^^^^^^^^^^^^^^^^^
2014-04-26 17:06:21 -04:00
`` filter:widgets.getWidgets ``
2014-04-25 19:09:40 -04:00
^^^^^^^^^^^^^^^^^^^^^
2014-04-26 17:06:21 -04:00
`` filter:search.query ``
2014-04-25 19:09:40 -04:00
^^^^^^^^^^^^^^^^^^^^^
2014-04-26 17:06:21 -04:00
`` filter:post.parse ``
2014-04-25 19:09:40 -04:00
^^^^^^^^^^^^^^^^^^^^^
2014-04-26 17:06:21 -04:00
`` filter:messaging.parse ``
2014-04-25 19:09:40 -04:00
^^^^^^^^^^^^^^^^^^^^^
2014-04-26 17:06:21 -04:00
`` filter:sounds.get ``
2014-04-25 19:09:40 -04:00
^^^^^^^^^^^^^^^^^^^^^
2014-04-26 17:06:21 -04:00
`` filter:post.getPosts ``
2014-04-25 19:09:40 -04:00
^^^^^^^^^^^^^^^^^^^^^
2014-04-26 17:06:21 -04:00
`` filter:post.getFields ``
2014-04-25 19:09:40 -04:00
^^^^^^^^^^^^^^^^^^^^^
2014-04-26 17:06:21 -04:00
`` filter:auth.init ``
2014-04-25 19:09:40 -04:00
^^^^^^^^^^^^^^^^^^^^^
2014-04-26 17:06:21 -04:00
`` filter:composer.help ``
2014-04-25 19:09:40 -04:00
^^^^^^^^^^^^^^^^^^^^^
2014-04-26 17:06:21 -04:00
`` filter:topic.thread_tools ``
2014-04-25 19:09:40 -04:00
^^^^^^^^^^^^^^^^^^^^^
2014-04-26 17:06:21 -04:00
`` filter:user.create ``
2014-04-25 19:09:40 -04:00
^^^^^^^^^^^^^^^^^^^^^
2014-04-26 17:06:21 -04:00
`` filter:widget.render ``
2014-04-25 19:09:40 -04:00
^^^^^^^^^^^^^^^^^^^^^
Actions
----------
2014-04-26 17:06:21 -04:00
`` action:app.load ``
2014-04-25 19:09:40 -04:00
^^^^^^^^^^^^^^^^^^^^^
**Argument(s)** : None
Executed when NodeBB is loaded, used to kickstart scripts in plugins (i.e. cron jobs, etc)
2014-04-26 17:06:21 -04:00
`` action:page.load ``
2014-04-25 19:09:40 -04:00
^^^^^^^^^^^^^^^^^^^^^
**Argument(s)** : An object containing the following properties:
2014-04-26 17:06:21 -04:00
* `` template `` - The template loaded
* `` url `` - Path to the page (relative to the site's base url)
2014-04-25 19:09:40 -04:00
2014-04-26 17:06:21 -04:00
`` action:plugin.activate ``
2014-04-25 19:09:40 -04:00
^^^^^^^^^^^^^^^^^^^^^
2014-04-26 17:06:21 -04:00
**Argument(s)** : A String containing the plugin's `` id `` (e.g. `` nodebb-plugin-markdown `` )
2014-04-25 19:09:40 -04:00
Executed whenever a plugin is activated via the admin panel.
2014-04-26 17:06:21 -04:00
**Important** : Be sure to check the `` id `` that is sent in with this hook, otherwise your plugin will fire its registered hook method, even if your plugin was not the one that was activated.
2014-04-25 19:09:40 -04:00
2014-04-26 17:06:21 -04:00
`` action:plugin.deactivate ``
2014-04-25 19:09:40 -04:00
^^^^^^^^^^^^^^^^^^^^^
2014-04-26 17:06:21 -04:00
**Argument(s)** : A String containing the plugin's `` id `` (e.g. `` nodebb-plugin-markdown `` )
2014-04-25 19:09:40 -04:00
Executed whenever a plugin is deactivated via the admin panel.
2014-04-26 17:06:21 -04:00
**Important** : Be sure to check the `` id `` that is sent in with this hook, otherwise your plugin will fire its registered hook method, even if your plugin was not the one that was deactivated.
2014-04-25 19:09:40 -04:00
2014-04-26 17:06:21 -04:00
`` action:post.save ``
2014-04-25 19:09:40 -04:00
^^^^^^^^^^^^^^^^^^^^^
**Argument(s)** : A post object (javascript Object)
Executed whenever a post is created or edited, after it is saved into the database.
2014-04-26 17:06:21 -04:00
`` action:email.send ``
2014-04-25 19:09:40 -04:00
^^^^^^^^^^^^^^^^^^^^^
2014-04-26 17:06:21 -04:00
`` action:post.setField ``
2014-04-25 19:09:40 -04:00
^^^^^^^^^^^^^^^^^^^^^
2014-04-26 17:06:21 -04:00
`` action:topic.edit ``
2014-04-25 19:09:40 -04:00
^^^^^^^^^^^^^^^^^^^^^
2014-04-26 17:06:21 -04:00
`` action:post.edit ``
2014-04-25 19:09:40 -04:00
^^^^^^^^^^^^^^^^^^^^^
2014-04-26 17:06:21 -04:00
`` action:post.delete ``
2014-04-25 19:09:40 -04:00
^^^^^^^^^^^^^^^^^^^^^
2014-04-26 17:06:21 -04:00
`` action:post.restore ``
2014-04-25 19:09:40 -04:00
^^^^^^^^^^^^^^^^^^^^^
2014-04-26 17:06:21 -04:00
`` action:config.set ``
2014-04-25 19:09:40 -04:00
^^^^^^^^^^^^^^^^^^^^^
2014-04-26 17:06:21 -04:00
`` action:topic.save ``
2014-04-25 19:09:40 -04:00
^^^^^^^^^^^^^^^^^^^^^
2014-04-26 17:06:21 -04:00
`` action:user.create ``
2014-04-25 19:09:40 -04:00
^^^^^^^^^^^^^^^^^^^^^
2014-04-26 17:06:21 -04:00
`` action:topic.delete ``
2014-05-01 14:37:46 -04:00
^^^^^^^^^^^^^^^^^^^^^
`` action:user.set ``
^^^^^^^^^^^^^^^^^^^^^
2014-05-01 16:21:58 -04:00
Parameters: field (str), value, type ('set', 'increment', or 'decrement')
Useful for things like awarding badges or achievements after a user has reached some value (ex. 100 posts)
`` action:settings.set ``
^^^^^^^^^^^^^^^^^^^^^
Parameters: hash (str), object (obj)
Useful if your plugins want to cache settings instead of pulling from DB everytime a method is called. Listen to this and refresh accordingly.