Pledge: Log the reason why a pledge was deactivated.

This commit is contained in:
Ian Dunn 2022-03-17 14:30:58 -07:00
parent ac25f4c008
commit d22f13f2c1
No known key found for this signature in database
GPG key ID: 99B971B50343CBCB
3 changed files with 24 additions and 4 deletions

View file

@ -205,7 +205,7 @@ function handle_activation_action( $post_id ) {
$sendback = remove_query_arg( array( 'deactivated', 'reactivated' ), $sendback );
if ( 'deactivate' === $action ) {
deactivate( $post_id );
deactivate( $post_id, false, 'Site admin deactivated via wp-admin list table.' );
wp_redirect( add_query_arg( 'deactivated', 1, $sendback ) );
exit();
} else {
@ -368,10 +368,11 @@ function create_new_pledge( $name ) {
*
* @param int $pledge_id The pledge to deactivate.
* @param bool $notify Whether the pledge admin should be notified of the deactivation.
* @param string $reason The reason why the pledge is being deactivated.
*
* @return int|WP_Error Post ID on success. Otherwise WP_Error.
*/
function deactivate( $pledge_id, $notify = false ) {
function deactivate( $pledge_id, $notify = false, $reason = '' ) {
$pledge = get_post( $pledge_id );
$result = wp_update_post(
array(
@ -385,6 +386,8 @@ function deactivate( $pledge_id, $notify = false ) {
Email\send_pledge_deactivation_email( $pledge );
}
do_action( FiveForTheFuture\PREFIX . '_deactivated_pledge', $pledge_id, $notify, $reason, $result );
return $result;
}