UR-4830: Fix Membership Renewal Reminder sent for subscriptions cancelled at period end - #1394
Open
Conversation
daily_membership_renewal_check() selected subscriptions using only status and next billing date. A membership cancelled at period end stays active until its end date, with the cancellation recorded in the urm_pending_cancel_<subscription_id> user meta, so it still matched and received a renewal reminder it will never act on. Skip those, matching the guard daily_membership_expiring_soon_check() already has.
Contributor
|
@tg-autopilot review |
There was a problem hiding this comment.
Pull request overview
Fixes renewal reminders being sent for subscriptions scheduled to cancel at period end.
Changes:
- Skips reminders when pending-cancellation metadata exists.
- Preserves reminders for active, non-cancelled subscriptions.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
All Submissions:
Changes proposed in this Pull Request:
A member who cancels a subscription at period end still receives the Membership Renewal Reminder email, telling them they are about to be billed for a membership they already cancelled.
Cause
When a subscription is cancelled while the paid period is still running, we intentionally keep it
activeuntil the end date and record the cancellation in user meta instead:daily_membership_renewal_check()then picks it up, becauseget_about_to_expire_subscriptions()filters on status and billing date only:Nothing in the loop consults the
urm_pending_cancel_<subscription_id>meta, so a cancelled-at-period-end membership matches and the reminder goes out.Fix
Skip subscriptions that already carry the pending-cancel meta. This is the same guard
daily_membership_expiring_soon_check()already has — it was applied there and missed here. Which of the two crons runs depends onuser_registration_renewal_behaviour(automatic→ renewal reminder,manual→ expiring soon), so sites on automatic renewal hit the unguarded path.Notification-only defect: no payment is taken and the subscription record is unaffected. Reported by a customer whose member cancelled on Stripe with
cancel_at_period_end, then received the reminder on the period end date itself.Closes # .
How to test the changes in this Pull Request:
Automaticwith the Renewal Reminder email enabled.next_billing_date/expiry_dateexists.activeandurm_pending_cancel_<subscription_id>user meta is set (the admin list shows "Cancels <date>").user_registration_membership_renewal_reminder_days_before/_periodsuch that today + window equalsnext_billing_date.urm_daily_membership_renewal_check(WP Crontrol, orwp cron event run urm_daily_membership_renewal_check).Types of changes:
Other information:
Changelog entry