Last active
August 3, 2016 20:34
-
-
Save zachskaggs/469935ff6c0847494402 to your computer and use it in GitHub Desktop.
Ninja Forms Timestamp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 == 1 ){ | |
//sets timestamp variable to current time | |
$timestamp = date('h:i:s A'); | |
//Update the hidden field value for the field with an ID of 3 to the current time. | |
$ninja_forms_processing->update_field_value( 3, $timestamp ); | |
} | |
} | |
add_action( 'ninja_forms_process', 'my_ninja_forms_date_code' ); |
Thanks - this works well. How does one add a timezone instead of defaulting to UTC?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi thanks for the snippet. I managed to get it working with no problems. I just wandered how the code can be expanded to work with multiple forms and hiiden fields.
Regards
Andrew