$timestamp を 1 つの Ninja Form 送信に追加できましたが、以下のコードを展開する方法がわからないため、複数のフォームで機能します。
これは、単一の忍者フォームで機能するコードです
<?php
/*
Plugin Name: Time Stamp
*/
function my_ninja_forms_date_code(){
//Declare $ninja_forms_processing as a global variable.
global $ninja_forms_processing;
//only process this code on the form ID 1
$form_id = $ninja_forms_processing->get_form_ID();
if( $form_id == 2 ){
//sets timestamp variable to current time
$timestamp = date('G:i:s');
//Update the hidden field value for the field with an ID of 41 to the
current time.
$ninja_forms_processing->update_field_value( 41, $timestamp );
}
}
add_action( 'ninja_forms_process', 'my_ninja_forms_date_code' );
?>
2 つのフォームに elseif 条件を追加しようとしましたが、受け入れられませんでした。以下のコードを参照してください。
<?php
/*
Plugin Name: Example Plugin
*/
<?php
function my_ninja_forms_date_code(){
//Declare $ninja_forms_processing as a global variable.
global $ninja_forms_processing;
//only process this code on the form ID 1
$form_id = $ninja_forms_processing->get_form_ID();
if( $form_id == 2 ){
//sets timestamp variable to current time
$timestamp = date('G:i:s');
//Update the hidden field value for the field with an ID of 3 to the current time.
$ninja_forms_processing->update_field_value( 41, $timestamp );
}
elseif ( $form_id == 6 ){
//sets timestamp variable to current time
$timestamp = date('G:i:s');
//Update the hidden field value for the field with an ID of 43 to the current time.
$ninja_forms_processing->update_field_value( 43, $timestamp );
}
}
add_action( 'ninja_forms_process', 'my_ninja_forms_date_code' );
?>
$form_id は、$ninja_forms_processing->update_field_value( 41, $timestamp ); の Ninja Form ID no と 41 を参照します。非表示のフィールド ID 番号から取得されます。
提案/ガイダンスは大歓迎です。