Manage Pledge: Allow pledge admins to change email (#113)

* Add the admin email field to the manage form
* Fix admin email processing: When the email is changed, the pledge needs to be set back to pending, until the email is re-confirmed
* Send confirmation emails for existing pledges to the "Manage Pledge" page
* Process the email confirmation & resending emails actions on both shortcodes
* Add a message for unconfirmed pledges
This commit is contained in:
Kelly Dwan 2019-11-26 15:37:19 -05:00 committed by GitHub
parent 544fe39199
commit 80b88399ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 139 additions and 65 deletions

View file

@ -280,10 +280,11 @@ function save_pledge( $pledge_id, $pledge ) {
save_pledge_meta( $pledge_id, $submitted_meta );
// Fired if the "Resend Confirmation" button was clicked in wp-admin.
if ( filter_input( INPUT_POST, 'resend-pledge-confirmation' ) ) {
Email\send_pledge_confirmation_email(
filter_input( INPUT_GET, 'resend-pledge-id', FILTER_VALIDATE_INT ),
get_page_by_path( 'for-organizations' )->ID
get_page_by_path( 'manage-pledge' )->ID
);
}
}
@ -350,8 +351,15 @@ function update_generated_meta( $meta_id, $object_id, $meta_key, $_meta_value )
update_post_meta( $object_id, META_PREFIX . 'org-domain', $domain );
break;
case META_PREFIX . 'pledge-email':
case META_PREFIX . 'org-pledge-email':
$landing_page = get_page_by_path( 'manage-pledge' )->ID;
Email\send_pledge_confirmation_email( $object_id, $landing_page );
delete_post_meta( $object_id, META_PREFIX . 'pledge-email-confirmed' );
// Flip pledge back to pending.
wp_update_post( array(
'ID' => $object_id,
'post_status' => 'pending',
) );
break;
}
}