Skip to content

Instantly share code, notes, and snippets.

@DumahX
Created December 13, 2021 15:15
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/feeeba317708731e96f0f0ed22bc5c96 to your computer and use it in GitHub Desktop.
Save DumahX/feeeba317708731e96f0f0ed22bc5c96 to your computer and use it in GitHub Desktop.
<?php
function cleanup_abandoned_signups($event) {
$txn = $event->get_data();
$user = $txn->user();
// Count complete transactions and non-complete transactions
$user_incomplete_txns = $user->transactions('`status` != "complete"');
$user_complete_txns = $user->transactions('`status` = "complete"');
// User only has non-complete transactions, so delete the user.
if(empty($user_complete_txns) && !empty($user_incomplete_txns)) {
$user->destroy();
}
}
add_action('mepr-event-after-signup-abandoned-reminder', 'cleanup_abandoned_signups');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment