Skip to main content

benecaster_signed_link_consumed

Action Free

Fires after an emailed signed link has been validated and spent, immediately before the recipient is redirected.

It runs after the token is consumed, which is the whole point. A replay of the same URL never reaches this hook, so a callback is free to do something non-idempotent here — recording a confirmed email address, crediting a one-time offer. Firing before consumption would let anyone holding a copy of the URL run it twice.

Fires once per link, on the first click only. Redirect and terminate from the callback to take over the destination entirely.

Parameters

Name Type Default Description
$user_id int — Recipient of the link.
$purpose string — One of the `SignedLink::PURPOSE_*` constants.
$show_id int — Show context, `0` when the link is not show-scoped.

Examples

Record that an address was confirmed by click

add_action( 'benecaster_signed_link_consumed', function ( int $user_id, string $purpose, int $show_id ): void {
    if ( \Benecaster\Support\SignedLink::PURPOSE_ACCOUNT_ACCESS !== $purpose ) {
        return;
    }

    update_user_meta( $user_id, '_my_addon_confirmed_email_at', time() );
}, 10, 3 );

Notes

This fires before the account is resolved, so it also runs for a link whose user was deleted between minting and clicking — that case then falls through to the same featureless refusal as a bad signature. Do not assume get_userdata( $user_id ) returns a user.

A signed link proves the holder received a specific email, nothing more. A forwarded message works for whoever opens it first. Do not treat this hook as proof of who is at the keyboard.

Need this built rather than just documented? See our services →