Create an entry in another form

By: David Costin | Asked: 10/13/2024
ForumsCategory: General questionsCreate an entry in another form
David Costin asked 1 month ago

I have copied this script from Formidable and all works fine, however, the script only copies one field (first field [1562]).  I have made an attempt to modify the script but with no success.  Any help would be welcome.

Regards David

add_action('frm_after_create_entry', 'create_entry_after_submission', 30, 2); function create_entry_after_submission($entry_id, $form_id){
if ( $form_id != 774 ) {//Change 774 to the ID of Form A
return;
} $form2 = '773';//Change 773 to the 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'][15162])){ //replace 15162 with the first field ID in Form A
return;
}
$new_value = $_POST['item_meta'][15162];//replace 15162 with the field id in line 15
//create entry
FrmEntry::create(array(
'form_id' => $form2,
'item_key' => 'entry', //change entry to a dynamic value if you would like
'frm_user_id' => $user,
'item_meta' => array(
15321 => $entry_id, //change 15321 to the ID of the first name field (in Form B) with the entry ID of Form A
15318 => $user,//change 15318 to the ID of the userID field in Form B
15163 => $new_value,//Change 15163 to the ID of a first name field in Form B you want to populate with a value from Form A
),
));
}

2 Answers
Rob LeVineRob LeVine answered 1 month ago
Add field id/value pairs to the item_meta array.
David Costin replied 1 month ago

Many thanks for your reply and advice. I will give this a try,

David Costin replied 1 month ago

Re your advice above, I have tried to use it but no success. Unfortunately my skills in using PHP is very rudimentary.

Rob LeVineRob LeVine replied 1 month ago

Post what you tried and what the results were.

David Costin answered 1 month ago
Many, many thanks for your offer of help.  Fortunately I have now solved my original problem. Regards David

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right