请原谅我是新来的,我根本不是编码员。我有一个使用 formidbale 表单的 WordPress 网站,我想在提交表单 A 时在表单 B 中创建条目。我偶然发现了这段代码,我将其粘贴在下面。我使用代码片段插件来实现此目的并且它有效,但问题是我想在下面的同一脚本中发送超过 1 个条目到表单 B,这可能吗?如果是这样我怎样才能实现它?
add_action('frm_after_create_entry', 'create_entry_after_submission', 30, 2);
function create_entry_after_submission($entry_id, $form_id){
if ( $form_id != 372 ) {//Change 372 to the ID of Form A
return;
}
$form2 = '373';//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'][6614])){ //replace 6614 with the field ID of the Form A value
return;
}
$new_value = $_POST['item_meta'][6614];
//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
6621 => $user,//change 6621 to the ID of the userID field in Form B
6622 => $new_value,//Change 6622 to the ID of a field in Form B you want to populate with a value from Form A
),
));
}
我尝试创建另一个脚本,但它没有同时运行,因此它在表单 b 中创建了 2 个表单条目。
检查此处 - 无需任何额外代码即可实现:https://formidableforms.com/knowledgebase/automatically-populate-fields/