Forked from strangerstudios/pmpro_clear_enddates.sql
Last active
April 17, 2020 09:51
-
-
Save andrewlimaza/6f7e08d6a0ef979b570365da7baf2b43 to your computer and use it in GitHub Desktop.
Clear out end dates for active subscriptions since the subs are managed by the gateway.
This file contains 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
# oops I had PMPro setup with recurring subscriptions AND expiration dates | |
# I really didn't need the expiration date because the subscription is managed by the gateway | |
# if payment fails, the gateway will try again based on its settings | |
# and when the gateway gives up, it will tell PMPro through IPN/webhook to cancel the subscription | |
# If I have expiration dates setup for recurring subscription, PMPro is going to cancel those subscriptions | |
# whether they pay or not. So I need to edit the level and remove the expiration date AND | |
# run this script to clear out the end dates for active subscriptions. | |
#### | |
# BACK UP YOUR DATABASE FIRST | |
#### | |
# Note: Your DB prefix may be something other than wp_, change the query to reflect that. | |
UPDATE wp_pmpro_memberships_users SET enddate = '0000-00-00 00:00:00' WHERE status = 'active'; | |
# If you have multiple membership levels and only certain levels need to be cleaned up, use a query like this. | |
# Ignore the query above and change the membership_id to what you need and note the DB prefix again | |
UPDATE wp_pmpro_memberships_users SET enddate = '0000-00-00 00:00:00' WHERE status = 'active' AND membership_id = 1; | |
##### UPDATE ONLY RECURRING USERS TO NOT HAVE AN EXPIRATION DATE | |
# Ignore above queries if you only want to affect members that have recurring billing set for a speifici level and note the DB prefix again | |
UPDATE wp_pmpro_memberships_users SET enddate = '0000-00-00 00:00:00' WHERE status = 'active' AND membership_id = 2 AND billing_amount > 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment