Pledge Form: Add ability to resend pledge confirmation email.

Fixes #49.
This commit is contained in:
Ian Dunn 2019-10-26 22:18:28 -07:00
parent 63f718bd9a
commit 3f774fdb78
No known key found for this signature in database
GPG key ID: 99B971B50343CBCB
5 changed files with 41 additions and 13 deletions

View file

@ -41,6 +41,11 @@ function render_form_new() {
$pledge_id = filter_input( INPUT_GET, 'pledge_id', FILTER_VALIDATE_INT ); $pledge_id = filter_input( INPUT_GET, 'pledge_id', FILTER_VALIDATE_INT );
$unverified_token = filter_input( INPUT_GET, 'auth_token', FILTER_SANITIZE_STRING ); $unverified_token = filter_input( INPUT_GET, 'auth_token', FILTER_SANITIZE_STRING );
$email_confirmed = process_pledge_confirmation_email( $pledge_id, $action, $unverified_token ); $email_confirmed = process_pledge_confirmation_email( $pledge_id, $action, $unverified_token );
} else if ( filter_input( INPUT_GET, 'resend_pledge_confirmation' ) ) {
$pledge_id = filter_input( INPUT_GET, 'pledge_id', FILTER_VALIDATE_INT );
$complete = true;
Pledge\send_pledge_confirmation_email( $pledge_id, get_post()->ID );
} }
ob_start(); ob_start();

View file

@ -221,6 +221,13 @@ function save_pledge( $pledge_id, $pledge ) {
save_pledge_meta( $pledge_id, $submitted_meta ); save_pledge_meta( $pledge_id, $submitted_meta );
if ( filter_input( INPUT_POST, 'resend-pledge-confirmation' ) ) {
Pledge\send_pledge_confirmation_email(
filter_input( INPUT_GET, 'resend-pledge-id', FILTER_VALIDATE_INT ),
get_page_by_path( 'for-organizations' )->ID
);
}
if ( filter_input( INPUT_POST, 'resend-contributor-confirmation' ) ) { if ( filter_input( INPUT_POST, 'resend-contributor-confirmation' ) ) {
PledgeForm\send_contributor_confirmation_emails( PledgeForm\send_contributor_confirmation_emails(
$pledge_id, $pledge_id,

View file

@ -156,7 +156,7 @@ function send_pledge_confirmation_email( $pledge_id, $action_page_id ) {
$message = $message =
'Thanks for committing to help keep WordPress sustainable! Please confirm this email address ' . 'Thanks for committing to help keep WordPress sustainable! Please confirm this email address ' .
'so that we can accept your pledge:' . "\n\n" . 'in order to publish your pledge:' . "\n\n" .
Email\get_authentication_url( $pledge_id, 'confirm_pledge_email', $action_page_id ) Email\get_authentication_url( $pledge_id, 'confirm_pledge_email', $action_page_id )
; ;

View file

@ -5,6 +5,7 @@ namespace WordPressDotOrg\FiveForTheFuture\View;
/** /**
* @var bool $email_confirmed * @var bool $email_confirmed
* @var string $directory_url * @var string $directory_url
* @var int $pledge_id
*/ */
?> ?>
@ -31,12 +32,17 @@ namespace WordPressDotOrg\FiveForTheFuture\View;
Your confirmation link has expired, please obtain a new one: Your confirmation link has expired, please obtain a new one:
</p> </p>
<form action="" method="get">
<input type="hidden" name="pledge_id" value="<?php echo esc_attr( $pledge_id ); ?>" />
<p> <p>
<button class="button-secondary"> <input
<?php esc_html_e( 'Resend confirmation email', 'wporg' ); ?> type="submit"
<?php // todo make ^ work when making the other 2 work ?> name="resend_pledge_confirmation"
</button> value="Resend Confirmation"
/>
</p> </p>
</form>
</div> </div>
<?php endif; ?> <?php endif; ?>

View file

@ -1,8 +1,14 @@
<?php <?php
namespace WordPressDotOrg\FiveForTheFuture\View;
/** @var array $data */ namespace WordPressDotOrg\FiveForTheFuture\View;
/** @var bool $readonly */ use WP_Post;
/**
* @var array $data
* @var bool $readonly
* @var WP_Post $pledge
*/
?> ?>
<div class="form-field"> <div class="form-field">
@ -29,9 +35,13 @@ namespace WordPressDotOrg\FiveForTheFuture\View;
<?php else : ?> <?php else : ?>
<span class="dashicons dashicons-warning" aria-hidden="true"></span> <span class="dashicons dashicons-warning" aria-hidden="true"></span>
<?php esc_html_e( 'Unconfirmed', 'wporg' ); ?> <?php esc_html_e( 'Unconfirmed', 'wporg' ); ?>
<button class="button-secondary"> <?php submit_button(
<?php esc_html_e( 'Resend confirmation', 'wporg' ); ?> 'Resend Confirmation',
</button> 'secondary',
'resend-pledge-confirmation',
false,
array( 'formaction' => add_query_arg( 'resend-pledge-id', $pledge->ID ) )
); ?>
<?php endif; ?> <?php endif; ?>
<?php endif; ?> <?php endif; ?>
</div> </div>