Created
April 19, 2018 22:38
-
-
Save Kiaminrut/98c9e199987d06d79aa104f82dfe0de5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Give Auto Approve Offline Donations | |
* | |
* If you would like to have donations skip the "pending" stage and auto-approve | |
* | |
* @param array $payment_args | |
* @param array $payment_data | |
* | |
* @return array @$payment_args | |
*/ | |
function give_auto_approve_offline_donations( $payment_args, $payment_data ) { | |
// Ensure gateway is set and check for offline gateway | |
if ( ! isset( $payment_data['gateway'] ) || $payment_data['gateway'] == 'gocardless' ) { | |
// Passthrough | |
return $payment_args; | |
} | |
// Only pending donations | |
if ( isset( $payment_args['post_status'] ) && $payment_args['post_status'] === 'pending' ) { | |
// Set post_status to complete / publish | |
$payment_args['post_status'] = 'publish'; | |
} | |
return $payment_args; | |
} | |
add_filter( 'give_insert_payment_args', 'give_auto_approve_offline_donations', 999, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment