Actions
| Action | Arguments | |
|---|---|---|
nahnu_links_event | $type, $data, $event. Every event. $event holds id, type, client_id, external_id, previous, source and created_at. | |
nahnu_links_{type} | $data, $event, with dots as underscores: nahnu_links_link_created, nahnu_links_client_updated, nahnu_links_domain_live, nahnu_links_invoice_paid, nahnu_links_click_created, nahnu_links_custom_campaign_sent. | |
nahnu_links_webhook_saved | `$webhook, ‘created’ \ | ‘updated’` |
nahnu_links_webhook_deleted | $id | |
nahnu_links_webhook_failed | $webhook, $delivery_id, $code, $response, once a delivery has used up its retries. | |
nahnu_links_partner_key_created, nahnu_links_partner_key_revoked | $key_id |
Events that happen in WordPress fire their actions straight away. Events from the edge script (API changes, clicks, conversions) fire during the next five-minute upkeep, with $event['source'] === 'edge'.
add_action( 'nahnu_links_domain_live', function ( $domain, $event ) {
my_app_notify( $event['external_id'], sprintf( '%s is ready', $domain['domain'] ) );
}, 10, 2 ); More examples#
Post to Slack when a link breaks
add_action( 'nahnu_links_link_broken', function ( $link, $event ) {
wp_remote_post( SLACK_WEBHOOK_URL, [
'headers' => [ 'Content-Type' => 'application/json' ],
'body' => wp_json_encode( [ 'text' => sprintf( 'Broken link: %s → %s', $link['short_url'], $link['destination_url'] ) ] ),
] );
}, 10, 2 ); Log every event while developing
add_action( 'nahnu_links_event', function ( $type, $data, $event ) {
error_log( sprintf( '[nahnu-links] %s %s', $type, wp_json_encode( $event['previous'] ?? null ) ) );
}, 10, 3 ); React to a paid invoice
add_action( 'nahnu_links_invoice_paid', function ( $invoice, $event ) {
// e.g. unlock something in your own plugin for $event['client_id']
}, 10, 2 ); Good to know#
- Keep handlers quick. Slow work belongs in a scheduled task.
- Handlers for edge events run during WordPress’s upkeep, so they need WordPress’s scheduled tasks to run. On quiet sites, set up a real cron job on your host.


