Hooks
17+ hooks — filter, action, and render override types. Priority ordering, content type filtering, and dispatch flow.
Hooks are the event system for plugins. Register a hook in the manifest, implement the function in your entry file, and RaisFast calls it at the right time.
Hook Types
| Type | Behavior |
|---|---|
| Filter | Chain transform. Receives input, returns modified data. Result passes to the next plugin. |
| Action | Fire-and-forget. Return value ignored. All plugins execute sequentially. |
| Render Override | First-wins. First plugin returning data wins; remaining plugins skipped. |
All Hooks
Content Lifecycle
| Hook | Type | When |
|---|---|---|
on-content-creating | Filter | Before content is created (modify data) |
on-content-created | Action | After content is created |
on-content-updating | Filter | Before content is updated (modify data) |
on-content-updated | Action | After content is updated |
on-content-deleted | Action | After content is deleted |
on-content-viewed | Action | When a single record is fetched by ID |
Post Lifecycle
| Hook | Type | When |
|---|---|---|
on-post-creating | Filter | Before a post is created |
on-post-created | Action | After a post is created |
on-post-updating | Filter | Before a post is updated |
on-post-updated | Action | After a post is updated |
on-post-deleted | Action | After a post is deleted |
Comment Lifecycle
| Hook | Type | When |
|---|---|---|
on-comment-creating | Filter | Before a comment is created |
on-comment-created | Action | After a comment is created |
on-comment-updated | Action | After a comment is updated |
on-comment-deleted | Action | After a comment is deleted |
Product & Order
| Hook | Type | When |
|---|---|---|
on-product-created | Action | After a product is created |
on-product-updated | Action | After a product is updated |
on-product-deleted | Action | After a product is deleted |
on-order-created | Action | After an order is created |
on-order-paid | Action | After an order is paid |
on-order-shipped | Action | After an order is shipped |
on-order-completed | Action | After an order is completed |
on-order-cancelled | Action | After an order is cancelled |
Payment & Wallet
| Hook | Type | When |
|---|---|---|
on-payment-order-created | Action | After a payment order is created |
on-payment-paid | Action | After payment succeeds |
on-payment-refunded | Action | After payment is refunded |
on-wallet-credited | Action | After wallet is credited |
on-wallet-debited | Action | After wallet is debited |
Tag & Category & Page & Media
| Hook | Type | When |
|---|---|---|
on-tag-created | Action | After a tag is created |
on-tag-updated | Action | After a tag is updated |
on-tag-deleted | Action | After a tag is deleted |
on-category-created | Action | After a category is created |
on-category-updated | Action | After a category is updated |
on-category-deleted | Action | After a category is deleted |
on-page-created | Action | After a page is created |
on-page-updated | Action | After a page is updated |
on-page-deleted | Action | After a page is deleted |
on-media-uploaded | Action | After a file is uploaded |
on-media-deleted | Action | After a file is deleted |
User & Auth
| Hook | Type | When |
|---|---|---|
on-user-registered | Action | After a user registers |
on-login | Action | After a user logs in |
on-password-reset-requested | Action | When password reset is requested |
on-email-verification-requested | Action | When email verification is requested |
Utility
| Hook | Type | When |
|---|---|---|
render-markdown | Render Override | Override markdown rendering |
filter-html | Render Override | Filter HTML output |
on-cron-tick | Action | Cron job fires |
Custom Events
Plugins can emit custom events via emitEvent(). Other plugins can listen by registering a hook matching the event type:
[hooks.order-created]
priority = 10export function order_created(input) {
const data = JSON.parse(input);
logInfo("order created: " + data.id);
}Priority Ordering
Hooks execute in ascending priority order (lower number = runs first):
[hooks.on-content-creating]
priority = 10 # runs first
[hooks.on-content-creating]
priority = 50 # runs second
[hooks.on-content-creating]
priority = 100 # runs last (default)Default priority is 100 if not specified.
For filter hooks, each plugin receives the output of the previous plugin in the chain. For action hooks, all plugins run independently.
Content Type Filtering
Limit a hook to specific content types:
[hooks.on-content-creating]
priority = 10
content_types = ["product", "course"]Or use the shorthand match:
[hooks.on-content-creating]
priority = 10
match = "product"When content_types is empty (default), the hook fires for all content types.
Filter Hooks
Filter hooks can modify data before it is saved. Return the modified data:
export function on_content_creating(input) {
const data = JSON.parse(input);
if (!data.slug) {
data.slug = data.title.toLowerCase().replace(/ /g, '-');
}
return JSON.stringify(data);
}Plugin.on_content_creating = function(input)
local data = sdk.extractJson(input, "body")
if not data.slug then
data.slug = string.lower(data.title):gsub(" ", "-")
end
return sdk.ok(data)
endfn on_content_creating(input) {
if input.slug == "" {
input.slug = to_lower(input.title);
input.slug = replace(input.slug, " ", "-");
}
input
}Action Hooks
Action hooks are for side effects — logging, notifications, cache invalidation. Return value is ignored:
export function on_content_created(input) {
const data = JSON.parse(input);
logInfo("created: " + data.id);
eventEmit("content.created", JSON.stringify({ id: data.id }));
}Plugin.on_content_created = function(input)
local data = sdk.extractJson(input, "body")
sdk.logInfo("created: " .. tostring(data.id))
sdk.eventEmit("content.created", sdk.jsonEncode({ id = data.id }))
endfn on_content_created(input) {
log("info", "created: " + input.id);
emit_event("content.created", to_json(input));
}Render Override Hooks
Render overrides use a first-wins strategy. The first plugin to return a non-null value wins, and the remaining plugins are skipped:
[hooks.render-markdown]
priority = 10export function render_markdown(input) {
const data = JSON.parse(input);
return customMarkdownRenderer(data.content);
}Error Recovery
- After 5 consecutive errors, the plugin is auto-disabled
- Error count resets to 0 on a successful invocation
- You can re-enable via Admin API:
POST /api/v1/admin/plugins/{id}/enable - Uncommitted transactions are automatically rolled back on timeout or crash
