"Create an entry in another form" php hook issue with 'save draft'

By: danny kim | Asked: 01/05/2024
ForumsCategory: Code Help"Create an entry in another form" php hook issue with 'save draft'
danny kim asked 11 months ago

Hi,
I am using "Create an entry in another form" hook with "Limit number of entries to one per" and "Allow logged-in users to save drafts" for Form Permissions.
When the entry was created, it should be a draft Form. So it can be single entry per a user. However it created entry and published. So, every time I use Form A, I get seprate form B entry unlimitely.
Anyone can help with this code?

```js
// Create an entry in another form
add_action('frm_after_create_entry', 'create_entry_after_submission', 30, 2);

function create_entry_after_submission($entry_id, $form_id){
if ( $form_id != 34 ) {//Change 372 to the ID of Form A
return;
}

$form2 = '9';//Change 373 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'][657])){ //replace 6614 with the field ID of the Form A value
return;
}

//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(
//6620 => $entry_id, //change 6620 to the ID of the field you want to populate (in Form B) with the entry ID of Form A
302 => $user,//change 6621 to the ID of the userID field in Form B
),
));
}
```

danny kim replied 11 months ago

There is some conflict issue with form B.
If I used the snippet where form A is only, it works well.
If the snippets are every page include form B, it has a conflict issue, so it wont give proper result as i expect.

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