Plugin SDK

Hooks reference

Every CRUD-style entity (article, category, media, user, preference, role, webset) fires the same family of events. The hook name is <entity>.<event>.

Generic write events

HookTypeWhen
<entity>.beforeSavefilterBefore any write — mutate the data
<entity>.afterSaveactionAfter any write
<entity>.beforeInsertactionBefore INSERT only
<entity>.afterInsertactionAfter INSERT only
<entity>.beforeUpdateactionBefore UPDATE only
<entity>.afterUpdateactionAfter UPDATE only
<entity>.beforeDeleteactionBefore DELETE
<entity>.afterDeleteactionAfter DELETE

Specials

HookTypePurpose
media.afterUploadactionFires after a file lands in /media/uploads/
user.afterLoginactionAfter a successful password verify
admin.menufilterAdd items to the admin sidebar
admin.dashboardCardsfilterAdd cards to the dashboard
admin.healthChecksfilterRegister entries for the health page
editor.toolbarButtonsfilterAdd buttons to the article editor

Examples

// Auto-lowercase article slugs before save
add_filter('article.beforeSave', function ($data) {
    $data['slug'] = strtolower($data['slug'] ?? '');
    return $data;
});

// Post to a webhook on publish
add_action('article.afterUpdate', function ($article, $id) {
    if ($article['status'] !== 'published') return;
    @file_get_contents('https://hooks.example.com/published?id=' . $id);
});

// Add a "Reports" item to the sidebar
add_filter('admin.menu', function ($items) {
    $items[] = [
        'label'     => 'Reports',
        'href'      => './plugins/reports/page.php',
        'icon'      => 'ic:round-bar-chart',
        'min_level' => 2,
    ];
    return $items;
});