Skip to content

Instantly share code, notes, and snippets.

@xnau
Created January 6, 2018 08:16
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 xnau/0f20a023bd4c13f7e1b9368f0ffcb562 to your computer and use it in GitHub Desktop.
Save xnau/0f20a023bd4c13f7e1b9368f0ffcb562 to your computer and use it in GitHub Desktop.
Demonstrates how to "unapprove" a record in Participants Database Member Payments if the account is not paid
<?php
/**
* @wordpress-plugin
* Plugin Name: Unapprove Unpaid Records
* Description: unapproves the record if the account has not been paid
*/
add_action( 'pdbmps-status_change_to_due', 'xnau_unapprove_unpaid_account' );
/**
* unapproves the record if the payment lapses
*
* this is fired on the "change_to_due" action because that is when the payment
* period expires. If the user pays before that (such as after the "payable" date),
* the account will not be unapproved because this action will never fire.
*
* @param array $data the user's record
*/
function xnau_unapprove_unpaid_account( $data )
{
if ( isset( $data['id'] ) && $record_id = $data['id'] ) {
Participants_Db::write_participant(array('approved' => 'no'), $record_id );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment