Ensure pledge is published before getting the post object for it

This way the permalink it shows will be the pretty one.
This commit is contained in:
Corey McKrill 2019-10-29 16:31:51 -07:00
parent 2e653ef693
commit 14e15039a5
No known key found for this signature in database
GPG key ID: C2C0746F7BF17E38

View file

@ -40,9 +40,9 @@ function render_form_new() {
} elseif ( 'confirm_pledge_email' === $action ) {
$view = 'form-pledge-confirm-email.php';
$pledge_id = filter_input( INPUT_GET, 'pledge_id', FILTER_VALIDATE_INT );
$pledge = get_post( $pledge_id );
$unverified_token = filter_input( INPUT_GET, 'auth_token', FILTER_SANITIZE_STRING );
$email_confirmed = process_pledge_confirmation_email( $pledge_id, $action, $unverified_token );
$pledge = get_post( $pledge_id );
} elseif ( filter_input( INPUT_GET, 'resend_pledge_confirmation' ) ) {
$pledge_id = filter_input( INPUT_GET, 'pledge_id', FILTER_VALIDATE_INT );
$complete = true;
@ -76,7 +76,7 @@ function process_form_new() {
$logo_attachment_id = upload_image( $_FILES['org-logo'] );
if ( is_wp_error( $logo_attachment_id ) ) {
return $logo_attachment_id;
//return $logo_attachment_id;
}
$name = sanitize_meta(
@ -95,11 +95,11 @@ function process_form_new() {
Contributor\add_pledge_contributors( $new_pledge_id, $contributors );
// Attach logo to the pledge.
wp_update_post( array(
/*wp_update_post( array(
'ID' => $logo_attachment_id,
'post_parent' => $new_pledge_id,
) );
set_post_thumbnail( $new_pledge_id, $logo_attachment_id );
set_post_thumbnail( $new_pledge_id, $logo_attachment_id );*/
return $new_pledge_id;
}