Skip to content

Instantly share code, notes, and snippets.

@christopherarter
Created June 7, 2015 19:14
Show Gist options
  • Save christopherarter/4418def82ca642c31442 to your computer and use it in GitHub Desktop.
Save christopherarter/4418def82ca642c31442 to your computer and use it in GitHub Desktop.
Gfcpt2
add_action( 'gform_after_submission_1', 'after_submission', 10, 2 );
function after_submission() {
// TEARDOWN POST TYPE STARTS HERE
$td_post_args = array(
'comment_status' => 'closed',
'ping_status' => 'closed',
'post_author' => $user_ID,
'post_title' => $entry[1],
'post_status' => 'draft',
'post_type' => 'teardown',
);
$post_id = wp_insert_post( $td_post_args );
// TEARDOWN CPT META VALUES
$td_meta_values = array(
'wpcf-td-mfg' => $entry[2],
'wpcf-td-model' => $entry[3],
'wpcf-td-msn' => $entry[4],
'wpcf-td-location' => $entry[7],
'wpcf-td-tail-number' => $entry[5],
'wpcf-td-last-operator' => $entry[6],
);
if ( $post_id > 0 ) {
foreach ( $td_meta_values as $key => $value ) {
update_post_meta( $post_id, $key, $value );
}
}
// ENGINE POST TYPE STARTS HERE
$engine_post_args = array(
'comment_status' => 'closed',
'ping_status' => 'closed',
'post_author' => $user_ID,
'post_title' => $entry[1],
'post_status' => 'draft',
'post_type' => 'engine',
);
$post_id = wp_insert_post( $engine_post_args );
$engine_meta_values = array(
'wpcf-td-engine-model' => $entry[11],
'wpcf-td-engine-pn' => $entry[13],
'wpcf-td-engine-qty' => $entry[14],
);
// The function below should be returning an integer, as I've confirmed it did indeed create the two posts, which would have post IDs'
if ( $post_id > 0 ) {
foreach ( $engine_meta_values as $key => $value ) {
update_post_meta( $post_id, $key, $value );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment