benecaster_bulk_enrollment_complete
Fires once, after the whole batch finishes processing — including on empty input — whether every row succeeded, some failed, or all failed.
It does not fire when BulkEnrollmentProcessor::enroll() refuses the batch before the first row by throwing — an unknown token type, a missing dependency, or a subscriber batch on a show whose active bridge is not the built-in membership (BulkEnrollBridgeNotBuiltin, including a show with no bridge at all). A queued job refused that way at the cron tick completes (status: complete) with every row an error (message: bridge_not_builtin) and still does not fire this action, because no row was processed. Listeners counting batches, or relying on one call per queued job, should not assume this action fires for every job that was started.
$skipped aggregates invalid-email rows and already-enrolled rows (plus, for a follower batch, rows refused by the unlicensed follower cap) into a single “no-op” bucket. For the breakdown, or for per-row detail, inspect the structured rows return value of BulkEnrollmentProcessor::enroll() rather than this action.
A batch can enroll subscribers on a tier, or free followers — check $token_type before treating $enrolled as new paying members. For a follower batch, $tier_slug is the show’s follower slug (not a gating tier), and $enrolled counts new followers including ones sent a double-opt-in confirmation instead of a token.
$token_type was appended as a sixth argument in a later release. Listeners registered with the original five arguments (accepted_args = 5) are unaffected; register with accepted_args = 6 to read it.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$show_id |
int |
— | ID of the show |
$tier_slug |
string |
— | Tier slug the batch enrolled into — for a follower batch, the show's follower slug |
$enrolled |
int |
— | Rows that produced a new subscription, or for followers a new follower (including confirmation-sent rows) |
$skipped |
int |
— | Invalid-email rows + already-enrolled rows (+ rows refused by the follower cap) |
$errors |
int |
— | Rows that threw during processing |
$token_type |
string |
— | `subscriber` or `follower`. Appended in a later release — omit it from your callback signature to keep working with the original five arguments. |
Examples
Alert admin when enrollments fail
add_action( 'benecaster_bulk_enrollment_complete', function (
int $show_id,
string $tier_slug,
int $enrolled,
int $skipped,
int $errors,
string $token_type
): void {
if ( $errors > 0 ) {
wp_mail(
get_option( 'admin_email' ),
'Bulk enrollment completed with errors',
"Show: {$show_id}. Type: {$token_type}. Enrolled: {$enrolled}. Skipped: {$skipped}. Errors: {$errors}."
);
}
}, 10, 6 );
Need this built rather than just documented? See our services →