Filters
| Filter | Arguments | Use |
|---|---|---|
nahnu_links_link_data | $data, $client_id, $link_id | Before a link is made ($link_id 0) or changed in WordPress. Return changed data, or a WP_Error to refuse. |
nahnu_links_client_data | $data, $client_id | The same for clients. |
nahnu_links_event_data | $data, $type, $client_id | What an event carries. |
nahnu_links_skip_event | false, $type, $data, $client_id | Return true to drop an event. |
nahnu_links_event_types | $types | The list of events. Add your custom.* types so they show on the Developers page. |
nahnu_links_webhook_payload | $payload, $webhook | The body of one delivery. |
nahnu_links_webhook_retries | [ 60, 300, 1800, 7200, 21600, 43200, 86400 ] | Seconds before each retry. |
nahnu_links_webhook_timeout | 8 | Seconds to wait for an answer. |
nahnu_links_event_days | 30 | Days events and deliveries are kept. |
nahnu_links_short_url | $url, $link | The address shown for a link. |
add_filter( 'nahnu_links_link_data', function ( $data, $client_id, $link_id ) {
if ( str_contains( $data['destination_url'] ?? '', 'competitor.com' ) ) {
return new WP_Error( 'not_allowed', 'Links to that site are not allowed.' );
}
return $data;
}, 10, 3 ); The edge script on Bunny can’t run PHP, so filters don’t change how redirects work, and they apply to changes made in WordPress. Changes made through the API on Bunny reach you as events.
More examples#
Always add UTM tags to links made in WordPress
add_filter( 'nahnu_links_link_data', function ( $data ) {
if ( ! empty( $data['destination_url'] ) && ! str_contains( $data['destination_url'], 'utm_source=' ) ) {
$data['destination_url'] = add_query_arg( 'utm_source', 'shortlink', $data['destination_url'] );
}
return $data;
} ); Register your own event type
add_filter( 'nahnu_links_event_types', function ( $types ) {
$types['custom.campaign_sent'] = 'A campaign was sent';
return $types;
} );
// Later:
nahnu_links_emit_event( 'custom.campaign_sent', [ 'campaign' => 'spring' ], $client_id ); Retry webhooks for longer
add_filter( 'nahnu_links_webhook_retries', fn() => [ 60, 300, 1800, 7200, 21600, 43200, 86400, 172800 ] ); Keep events for 90 days
add_filter( 'nahnu_links_event_days', fn() => 90 ); Where filters apply#
| Change made in | Filters run? |
|---|---|
| The WordPress dashboard | Yes |
| PHP functions | Yes |
| The client dashboard and AI assistants | Yes |
| The client or partner API, client sites | No: these run on Bunny. You get the events instead. |


