Skip to main content

Keep your own record of who you have chased

Premium Beginner

The migration dashboard shows how many times you have resent each person’s welcome email, but not when, or who on your team clicked. benecaster_migration_invite_resent fires each time somebody clicks Resend, so this recipe logs every chase against the show.

Do not send an email of your own from this hook. The resend has already queued the Migration Welcome, and the person is marked as emailed today so the automated reminders leave them alone — one migration email a day is the ceiling. A second message from your callback puts two emails in front of them on the same morning, from a domain already doing the largest send it has ever made.

It fires only for a resend somebody clicked, never for the automated emails, and never when the resend was refused. If you want every migration email, use the email hooks for the five migration_* types instead.

Code

<?php
// Log every chase against the show, for a weekly digest.
add_action( 'benecaster_migration_invite_resent', function ( int $patron_id, int $import_id, int $show_id ): void {
    $log   = get_post_meta( $show_id, 'my_migration_chases', true );
    $log   = is_array( $log ) ? $log : [];
    $log[] = [
        'patron_id' => $patron_id,
        'import_id' => $import_id,
        'by'        => get_current_user_id(),
        'at'        => gmdate( 'Y-m-d H:i:s' ),
    ];

    update_post_meta( $show_id, 'my_migration_chases', $log );
}, 10, 3 );

View on GitHub →

Hooks Used

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