Skip to content

Commit

Permalink
Use CMB2::save_fields() instead of doing our own saving. Solves the t…
Browse files Browse the repository at this point in the history
…axonomy problem
  • Loading branch information
jtsternberg committed Apr 6, 2017
1 parent 207c121 commit 0af64bd
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions front-end/cmb2-front-end-submit.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ function wds_handle_frontend_new_post_form_submission() {
return $cmb->prop( 'submission_error', $new_submission_id );
}

$cmb->save_fields( $new_submission_id, 'post', $sanitized_values );

/**
* Other than post_type and post_status, we want
* our uploaded attachment post to have the same post-data
Expand All @@ -213,18 +215,6 @@ function wds_handle_frontend_new_post_form_submission() {
set_post_thumbnail( $new_submission_id, $img_id );
}

// Loop through remaining (sanitized) data, and save to post-meta
foreach ( $sanitized_values as $key => $value ) {
if ( is_array( $value ) ) {
$value = array_filter( $value );
if( ! empty( $value ) ) {
update_post_meta( $new_submission_id, $key, $value );
}
} else {
update_post_meta( $new_submission_id, $key, $value );
}
}

/*
* Redirect back to the form page with a query variable with the new post ID.
* This will help double-submissions with browser refreshes
Expand Down

0 comments on commit 0af64bd

Please sign in to comment.