次のコードを使用して、Wordpress の Formidable プラグインを使用してフィールド値を更新しています。
// Order Update Mgmt: Status
add_action('frm_after_create_entry', 'order_mgmt_status', 30, 2);
function order_mgmt_status($entry_id, $form_id){
if($form_id == 25){ //change 25 to the ID of your update form
global $wpdb, $frmdb, $frm_entry_meta;
$order_id = $_POST['item_meta'][1252]; //change 1252 to the ID of the field containing the primary key
$new_status = $_POST['item_meta'][1245]; //change 1245 to the ID of the field containing the new data to insert
$old_status = 368; //change 368 to the ID of field on the master form containing the old data
$wpdb->update($frmdb->entry_metas, array('meta_value' => $new_status), array('item_id' => $order_id, 'field_id' => $old_status));
}
}
これはエラーなしで完全に機能します。
ただし、コードを複製すると、WordPress のインストールが中断されます (死の白い画面)。私は次のことをしますが:
- 「order_mgmt_status」を新しい関数名に変更します
- そして、テストするために、グローバル行 $wpdb->update 行もコメントアウトし、複製されたコードの変数の名前を変更しました。
- 各フィールドに対して新しい add_action エントリを実行して更新し、複数の関数を呼び出して各フィールドを更新する単一の add_action エントリを実行してテストしました。これらのどちらも機能しませんでした。
解決策のアイデアは大歓迎です!