Skip to content

Extension Points

All public WordPress hooks provided by the middag-account plugin. Third-party plugins and satellites can use these to extend behavior without modifying core code.

Every hook uses the middag prefix. Domain events follow the pattern middag/{domain}/{event}.

Lifecycle Actions

HookParametersDescription
middag_activatednoneFired after plugin activation, CPTs registered
middag_deactivatednoneFired after plugin deactivation, cron cleared
php
add_action('middag_activated', function (): void {
    // Satellite plugin setup that depends on middag-account
});

Domain Event Actions

Domain events are dispatched via do_action("middag/{domain}/{event}", ...$payload).

Entitlement Events

HookParameters
middag/entitlement/createdEntitlementEntity $entitlement
middag/entitlement/provisionedEntitlementEntity $entitlement
middag/entitlement/status_changedEntitlementEntity $entitlement, string $old, string $new
middag/entitlement/suspendedEntitlementEntity $entitlement, string $reason
middag/entitlement/reactivatedEntitlementEntity $entitlement
middag/entitlement/cancelledEntitlementEntity $entitlement, string $reason
php
add_action('middag/entitlement/provisioned', function (EntitlementEntity $ent): void {
    if ($ent->class === 'PLG') {
        // Auto-activate license for plugin entitlements
    }
}, 10, 1);

Quote Events

HookParameters
middag/quote/createdQuoteEntity $quote
middag/quote/acceptedQuoteEntity $quote
middag/quote/rejectedQuoteEntity $quote
middag/quote/paidQuoteEntity $quote
middag/quote/status_changedQuoteEntity $quote, string $old, string $new

The middag/quote/paid event triggers the auto-provisioning pipeline. QuoteEntitlementHooks listens at priority 10 to create entitlements from paid quotes.

Environment Events

HookParameters
middag/environment/createdEnvironmentEntity $environment
middag/environment/status_changedEnvironmentEntity $environment, string $old, string $new

Service Events

HookParameters
middag/service/createdServiceEntity $service
middag/service/status_changedServiceEntity $service, string $old, string $new

Ticket Events

HookParameters
middag/ticket/createdTicketEntity $sr
middag/ticket/status_changedTicketEntity $sr, string $old, string $new

Email Events

Dispatched through WordPressEventDispatcher and consumed by EmailEventListener:

Event NameEmail Template
auth.register_email_onlyAuthRegisterEmailOnly
auth.reset_passwordAuthResetPassword
auth.verify_accountAuthVerifyAccount
auth.welcomeAuthWelcome
collaborator.invite_sentCollaboratorInvite
collaborator.invite_acceptedCollaboratorAcceptedInvite
collaborator.invite_rejectedCollaboratorRejectedInvite
collaborator.permissions_updatedCollaboratorPermissionsUpdated
collaborator.removedCollaboratorRemoved

WordPress hook name is middag/{eventName} (e.g., middag/auth.welcome).

Filter Hooks

middag_password_requirements

Override password validation rules (default follows NIST SP 800-63B):

php
add_filter('middag_password_requirements', function (array $req): array {
    $req['min_length'] = 12;
    return $req;
});

Default: ['min_length' => 8, 'require_uppercase' => true, 'require_lowercase' => true, 'require_number' => true]

middag_rate_limit_whitelist

IPs exempt from API rate limiting. Default: ['127.0.0.1', '::1'].

php
add_filter('middag_rate_limit_whitelist', function (array $list): array {
    $list[] = '10.0.0.1';
    return $list;
});

middag_email_event_map

Add or override event-to-email-template mappings:

php
add_filter('middag_email_event_map', function (array $map): array {
    $map['order.completed'] = function (array $payload): void {
        (new MyOrderEmail())->trigger($payload['email'], $payload['order_id']);
    };
    return $map;
});

middag_email_print_button_color

Override CTA button color in service email templates. Default: WooCommerce base color.

middag_email_button_url

Override CTA button URL in "new site" email. Receives (string $url, array $cct).

Cron Hooks

Registered by CronRegistrar, cleared on deactivation:

Hook NameIntervalDescription
middag_every_minute60sHigh-frequency background tasks
middag_five_minutes5 minClock-aligned (e.g., :00, :05)
middag_fifteen_minutes15 minMedium-frequency sync
middag_thirty_minutes30 minIntegration polling
middag_hourly1 hourClock-aligned hourly tasks
middag_twicedaily12 hoursTwice-daily maintenance
middag_daily_morning24 hoursDaily at 06:00 server time

Stability Contract

Existing hooks are never removed. New parameters are always appended to the end. This guarantee applies within the v1 lifecycle.