Skip to content

Instantly share code, notes, and snippets.

@supercleanse
Last active September 10, 2018 20:59
Show Gist options
  • Save supercleanse/23c73f0a181547bd42ec36cd7a41451e to your computer and use it in GitHub Desktop.
Save supercleanse/23c73f0a181547bd42ec36cd7a41451e to your computer and use it in GitHub Desktop.
<?php
require './wp-load.php'; // only necessary if you run this script on the command line
$membership_id = 8888; // Change this to whatever your membership_id is
$m = new MeprProduct($membership_id);
$subscription_table = 'wp_mepr_subscriptions'; // change this to whatever your subscriptions table is named
$q = $wpdb->prepare("
SELECT s.id
FROM {$subscription_table} AS s
WHERE s.product_id = %d
AND s.status NOT IN ('pending','cancelled')
",
$membership_id
);
$sub_ids = $wpdb->get_col($q);
foreach($sub_ids as $sid) {
$s = new MeprSubscription($sid);
if(!$s->is_lifetime() && !$s->is_expired()) {
$txn = $s->latest_txn();
if(!empty($txn) && $txn instanceof MeprTransaction) {
$txn->expires_at = MeprUtils::db_lifetime();
$txn->store();
error_log("Changed Subscription {$sid} to lifetime by setting Transaction {$txn->id} Expires At to {$txn->expires_at}");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment