Skip to content

Instantly share code, notes, and snippets.

@DumahX
Created December 10, 2021 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DumahX/14c6c21ef00b3123d57fb4663e761e0f to your computer and use it in GitHub Desktop.
Save DumahX/14c6c21ef00b3123d57fb4663e761e0f to your computer and use it in GitHub Desktop.
<?php
function subscription_stopped_func($event) {
$sub = $event->get_data();
$latest_txn = $sub->latest_txn();
if ($sub->in_trial() && $latest_txn) {
// Set transaction's expiration date to yesterday. Effectively revokes their membership access.
$latest_txn->expires_at = MeprUtils::ts_to_mysql_date(time() - MeprUtils::days(1));
$latest_txn->store();
}
}
add_action('mepr-event-subscription-stopped', 'subscription_stopped_func');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment