Created
January 5, 2018 15:17
-
-
Save mwhiteley16/2bacdd9d9b920c20af6d3711c6bccc6b to your computer and use it in GitHub Desktop.
Create Post when Gravity Form Submitted
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create Field Staff post when subscription is completed | |
add_action( 'gform_after_submission_4', 'wd_create_map_post', 10, 4); | |
function wd_create_map_post($entry, $form) { | |
global $post; | |
global $wp_query; | |
$name_first = $entry['10.3']; | |
$name_last = $entry['10.6']; | |
$state = $entry['12']; | |
$state_value = array( "$state" ); | |
$zip = $entry['13']; | |
$post_title = "$name_first" . " $name_last"; | |
$map_post = array( | |
'post_type' => 'fieldstaff-map', | |
'post_title' => $post_title, | |
'post_content' => ' ', | |
'post_status' => 'draft', | |
'post_author' => 349 /* Matt's User ID */ | |
); | |
$postID = wp_insert_post( $map_post ); | |
update_field( 'field_5a4bd0dbb43c5', $state_value, $postID ); // Update ACF state field | |
update_field( 'field_5a4bd140b43c6', $zip, $postID ); // Update ACF state field | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment