Run your own code when a site-wide Outlinks link is created
These fire around each new site-wide link, a tracked /go/ link that belongs to no show:
benecaster_outlinks_site_link_create_before( string $url, string $slug ): the cleaned destination and the name about to be used, immediately before the link is created.benecaster_outlinks_site_link_create_after( int $redirect_id, string $url, string $slug ): once the link is created.
They fire the same way from benecaster_outlinks_site_link(), POST /benecaster-outlinks/v1/site-links and the Add link form on Settings → Site-wide Links. Nothing fires when an existing link is found and returned, or for a request refused before anything is written (an unusable URL or name).
Code
<?php
add_action( 'benecaster_outlinks_site_link_create_after', function ( int $redirect_id, string $url, string $slug ): void {
error_log( sprintf( 'Outlinks site-wide link %d: /go/%s -> %s', $redirect_id, $slug, $url ) );
}, 10, 3 );
Hooks Used
Need this built rather than just documented? See our services →