add_action('frm_after_create_entry', 'create_entry_after_submission', 60, 2);I'm a novice coder so I've just hacked this together until it worked. If any boffins out there can see any issues or any ways to improve it I'd be much obliged!
function create_entry_after_submission($entry_id, $form_id){
if ( $form_id != 2 ) { //ID of Form A
return;
}
//Get the initial form entry and find the post_id of the post created by this entry.
$entry = FrmEntry::getOne( $entry_id );
if ( ! $entry->post_id ) {
return;
}
$form2 = '4'; //ID of Form B
//Get user
if (!isset($_POST['frm_user_id'])){
return;
}
$user = $_POST['frm_user_id'];
//get data
if (!isset($_POST['item_meta'][84])){ //84 is the field ID of the Form A value
return;
}
$studio_post_id = $entry->post_id; //assign the post_id to this variable
$artist_name = $_POST['item_meta'][84];
$artist_description = $_POST['item_meta'][229];
//create entry
FrmEntry::create(array(
'form_id' => $form2,
'item_key' => $user . $entry_id,
'frm_user_id' => $user,
'item_name' => $artist_name,
'item_meta' => array(
171 => $user,
225 => $studio_post_id,//Put the post_id into the correct field of the new form entry
98 => $artist_name,
121 => $artist_description,
),
));
}
Please login or Register to submit your answer