Skip to content

Instantly share code, notes, and snippets.

@strangerstudios
Last active April 8, 2021 18:32

Revisions

  1. @ideadude ideadude revised this gist Oct 12, 2017. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions pmpro_clear_enddates.sql
    Original file line number Diff line number Diff line change
    @@ -12,5 +12,5 @@
    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, remove the # in front, 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;
    # 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;
  2. @ideadude ideadude created this gist Oct 12, 2017.
    16 changes: 16 additions & 0 deletions pmpro_clear_enddates.sql
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    # 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, remove the # in front, 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;