Skip to main content

Reshape, or act on, the list of migration emails that did not send

Premium Intermediate

The migration dashboard lists every migration email that could not be sent, under Emails that did not send. benecaster_migration_failed_sends filters that whole list before the panel draws it, and benecaster_migration_failed_send_retried fires when a podcaster clicks Send again on a failed welcome. This recipe keeps the panel to welcomes only and tells your helpdesk about each retry.

Keep the counts true when you remove rows. The list shows at most 100 of each email type, so total can be larger than the number shown, and truncated says so. Those are worked out before your filter runs. If you drop rows without setting them again, the panel says it is showing part of a list whose rest will never appear.

Do not change retryable. Only a failed welcome to somebody still mid-move, whose WordPress account still exists, can be sent again: every migration email is stored as it was written on the day it was queued, so a late reminder would show a deadline that has passed.

A retry is not a chase. Nothing is recorded against the person, so their next reminder still goes out. That is the opposite of benecaster_migration_invite_resent, which fires for Resend. The action fires once the email is back in the queue, not once it is delivered.

Code

<?php
// Keep the panel to the welcome only — the other four are informational.
add_filter(
    'benecaster_migration_failed_sends',
    function ( array $payload, int $import_id, int $show_id ): array {
        $payload['items'] = array_values( array_filter(
            $payload['items'],
            static fn ( array $row ): bool => 'migration_welcome' === $row['emailType']
        ) );
        // Keep the counts true to what is left, or the panel says
        // "Showing 3 of 10" about rows that will never appear.
        $payload['total']     = (int) ( $payload['byType']['migration_welcome'] ?? 0 );
        $payload['shown']     = count( $payload['items'] );
        $payload['truncated'] = $payload['shown'] < $payload['total'];

        return $payload;
    },
    10,
    3
);

// Tell your own helpdesk when a podcaster retries one.
add_action(
    'benecaster_migration_failed_send_retried',
    function ( int $queue_id, int $import_id, int $show_id ): void {
        my_support_log( "migration {$import_id}: queue row {$queue_id} retried" );
    },
    10,
    3
);

View on GitHub →

Hooks Used

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