BulkEnrollmentJobRunner
Benecaster\Subscribers\BulkEnrollmentJobRunner
Asynchronous WP-Cron orchestrator for bulk subscriber enrollment. Mirrors the architecture of FeedBulkImporter — jobs are queued in wp_options, processed batch-by-batch via cron, and tracked with per-job progress records.
Job Lifecycle
- Submit —
BulkEnrollmentJobRunner::submit()validates the input, assigns a unique$job_id, stores the job in_benecaster_enroll_job_{job_id}, and schedules a WP-Cron event. - Cron fires — the handler calls
BulkEnrollmentProcessor::enroll()with the batch, then updates the progress record. - Completion — when the final batch finishes, the job record is deleted and
benecaster_bulk_enrollment_completefires.
One-Active-Job-Per-Show Constraint
Only one bulk enrollment job may run at a time per show. The constraint is enforced via the option _benecaster_enroll_active_job_{show_id}:
- Set to
$job_idwhen a job starts - Cleared on completion or cancellation
Attempting to submit a second job while one is active returns a 409 Conflict response from the REST endpoint.
wp_option Keys
| Key | Contents |
|---|---|
_benecaster_enroll_job_{job_id} |
Serialised job payload: show_id, tier_slug, emails array, submitted timestamp |
_benecaster_enroll_progress_{job_id} |
Running totals: enrolled, skipped, errors, processed, total |
_benecaster_enroll_active_job_{show_id} |
Currently active $job_id for the show, or absent when no job is running |
Progress Polling
The REST API exposes a GET /shows/{show_id}/subscribers/bulk-enroll/status endpoint that reads _benecaster_enroll_progress_{job_id} and returns current progress. The admin screen polls this endpoint at a 2-second interval while a job is running.
See Bulk Enroll REST API for the full endpoint specification.