No worries, I know this isn't really the right forum for gravity forms help, they seem to be lacking in that area. I created this solution and added to my functions file and so far it works great. Here is the form i'm using. hidden link
So it will create from 1 to 5 donation posts depending the users additional donations form selection.
Thanks for the help Caridad, your the best!
<?php
add_action("gform_after_submission_2", "create_donation_content", 10, 2);
function create_donation_content($entry, $form){
//getting post
$post = get_post($entry["post_id"]);
//adding post args array and setting to donations post type
$donation_post_args = array(
'comment_status' => 'closed', // or open
'ping_status' => 'closed',
'post_author' => 1, // this represents admin by default.
// might need to pull user info if is real user
'post_title' => $entry[59] . ' ' . $entry[60], // this will get the donors name
'post_status' => 'publish',
'post_type' => 'donation',
);
//Start Additional Donation 2 logic
//need to test if 2nd donation field has a value before creating a new post, this donation field id is 12
$greenlight = $entry[12];
if($greenlight == ""){
} else {
//inserting a new donation
$post_id = wp_insert_post( $donation_post_args );
// add more meta values if you need
$donation_meta_values = array(
'wpcf-donation-1' => $entry[12],
'wpcf-donation-rider-id' => $entry[8],
'wpcf-donation-anonymous' => $entry["65"],
//fields below will not change
'wpcf-donor-first-name' => $entry[59],
'wpcf-donor-last-name' => $entry[60],
'wpcf-donor-email' => $entry[64],
'wpcf-donor-phone' => $entry[62],
'wpcf-donor-address' => $entry["19.1"] . '
' . $entry["19.3"] . '
' .$entry["19.4"] . '
' . $entry["19.5"] . '
' . $entry["19.6"]
);
// as long as wp_insert_post didnt fail...
if($post_id > 0){
foreach($donation_meta_values as $key => $value) {
// add our post meta
update_post_meta($post_id, $key, $value);
}
}
//updating post
wp_update_post($post);
}//end if test
// End Additional Donation 2 logic////////////////////////////////////
//Start Additional Donation 3 logic
//need to test if 3nd donation field has a value before creating a new post, this donation field id is 25
$greenlight3 = $entry[25];
if($greenlight3 == ""){
} else {
//inserting a new donation
$post_id = wp_insert_post( $donation_post_args );
// add more meta values if you need
$donation_meta_values = array(
'wpcf-donation-1' => $entry[25],
'wpcf-donation-rider-id' => $entry[24],
'wpcf-donation-anonymous' => $entry["68"],
//fields below will not change
'wpcf-donor-first-name' => $entry[59],
'wpcf-donor-last-name' => $entry[60],
'wpcf-donor-email' => $entry[64],
'wpcf-donor-phone' => $entry[62],
'wpcf-donor-address' => $entry["19.1"] . '
' . $entry["19.3"] . '
' .$entry["19.4"] . '
' . $entry["19.5"] . '
' . $entry["19.6"]
);
// as long as wp_insert_post didnt fail...
if($post_id > 0){
foreach($donation_meta_values as $key => $value) {
// add our post meta
update_post_meta($post_id, $key, $value);
}
}
//updating post
wp_update_post($post);
}//end if test
// End Additional Donation 3 logic
//Start Additional Donation 4 logic
//need to test if 4th donation field has a value before creating a new post, this donation field id is 29
$greenlight4 = $entry[29];
if($greenlight4 == ""){
} else {
//inserting a new donation
$post_id = wp_insert_post( $donation_post_args );
// add more meta values if you need
$donation_meta_values = array(
'wpcf-donation-1' => $entry[29],
'wpcf-donation-rider-id' => $entry[27],
'wpcf-donation-anonymous' => $entry["69"],
//fields below will not change
'wpcf-donor-first-name' => $entry[59],
'wpcf-donor-last-name' => $entry[60],
'wpcf-donor-email' => $entry[64],
'wpcf-donor-phone' => $entry[62],
'wpcf-donor-address' => $entry["19.1"] . '
' . $entry["19.3"] . '
' .$entry["19.4"] . '
' . $entry["19.5"] . '
' . $entry["19.6"]
);
// as long as wp_insert_post didnt fail...
if($post_id > 0){
foreach($donation_meta_values as $key => $value) {
// add our post meta
update_post_meta($post_id, $key, $value);
}
}
//updating post
wp_update_post($post);
}//end if test
// End Additional Donation 4 logic
//Start Additional Donation 5 logic
//need to test if 4th donation field has a value before creating a new post, this donation field id is 29
$greenlight5 = $entry[33];
if($greenlight5 == ""){
} else {
//inserting a new donation
$post_id = wp_insert_post( $donation_post_args );
// add more meta values if you need
$donation_meta_values = array(
'wpcf-donation-1' => $entry[33],
'wpcf-donation-rider-id' => $entry[32],
'wpcf-donation-anonymous' => $entry["70"],
//fields below will not change
'wpcf-donor-first-name' => $entry[59],
'wpcf-donor-last-name' => $entry[60],
'wpcf-donor-email' => $entry[64],
'wpcf-donor-phone' => $entry[62],
'wpcf-donor-address' => $entry["19.1"] . '
' . $entry["19.3"] . '
' .$entry["19.4"] . '
' . $entry["19.5"] . '
' . $entry["19.6"]
);
// as long as wp_insert_post didnt fail...
if($post_id > 0){
foreach($donation_meta_values as $key => $value) {
// add our post meta
update_post_meta($post_id, $key, $value);
}
}
//updating post
wp_update_post($post);
}//end if test
// End Additional Donation 5 logic
};// End add_action