Skip to main content

GracePeriodExpiryCheck

Benecaster\Cron\GracePeriodExpiryCheck

Daily cron class that manages the two-pass grace period lifecycle for Promote to Bridge subscribers.

Schedule

Registered on the daily WP-Cron event. Runs once every 24 hours.

Two Passes per Tick

Each cron run executes two independent passes:

Expiry Pass

Queries benecaster_subscriptions for rows where promote_grace_period_ends_at is in the past and the subscription status is not yet expired_grace.

For each matching row:

  1. Revokes the subscriber’s feed token
  2. Sets subscription status to expired_grace
  3. Queues a promote_grace_expired email
  4. Fires benecaster_promote_grace_expired action

Reminder Pass

Queries for rows where promote_grace_period_ends_at is between 6 and 8 days from now and status is still active.

For each matching row:

  1. Checks for a transient benecaster_grace_reminder_sent_{subscription_id} — if present, skips (reminder already sent this window)
  2. Queues a promote_grace_reminder email
  3. Sets the transient with a 9-day TTL to prevent re-sending

The 6–8 day window and the transient TTL ensure that the reminder fires exactly once regardless of how many daily cron ticks fall within the window.