Start your code here
add_action('frm_after_create_entry', 'copy_into_my_table', 20, 2); function copy_into_my_table($entry_id, $form_id){ if($form_id == 4){ //change 4 to the form id of the form to copy global $wpdb; $values = array('col_name1' => $_POST['item_meta'][25],now i need to get created_at time and insert to another table every everyting is ok but created at now working
'col_name2' => $_POST['item_meta'][26]),
'Created_at' => $_POST[created_at]),; //replace 25 and 26 with the field ids of the Formidable form. Change col_name to the column names in your table $wpdb->insert('table_name', $values); } }
Thanks for response Rob i am add this variable for resolve problem:
Start your code here
$now_time = wp_date('Y-m-d G:i:s');
'createdate' => $now_time
and finally code:
Start your code here
add_action('frm_after_create_entry', 'copy_into_my_table', 20, 2); function copy_into_my_table($entry_id, $form_id){ if($form_id == 4){ //change 4 to the form id of the form to copy global $wpdb; $now_time = wp_date('Y-m-d G:i:s'); $values = array('col_name1' => $_POST['item_meta'][25], 'col_name2' => $_POST['item_meta'][26]), 'Created_at' => $now_time; //replace 25 and 26 with the field ids of the Formidable form. Change col_name to the column names in your table $wpdb->insert('table_name', $values); } }
Your solution will give you the time when it hits that code, not when the entry was created, it will be a few milliseconds different (you will end up with the original entry with time X and your new entry with time [X + some small amount]). If that's what you want, that's fine, but my point is that what you're doing is not what you asked about.
You mentioned a good point, it's absolutely correct, but for my project, the difference of a few milliseconds doesn't matter,
Considering that your code is also executed in the function, will this difference be a few milliseconds or not?
The code is executed in the function, but it's getting a value that was previously set. If you use my method, the crreated_at value will match exactly between the two entries.
Thanks Rob,
The reason why I did not use your code was that the time was not saved according to the time zone I wanted
Please login or Register to submit your answer