Skip to content

Instantly share code, notes, and snippets.

@zachskaggs
Last active August 3, 2016 20:34
Show Gist options
  • Save zachskaggs/469935ff6c0847494402 to your computer and use it in GitHub Desktop.
Save zachskaggs/469935ff6c0847494402 to your computer and use it in GitHub Desktop.
Ninja Forms Timestamp
<?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' );
@echoleaf
Copy link

echoleaf commented Aug 3, 2016

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