Entry Date Updated into Hidden Field

I am having trouble getting an entry’s update date and time into a hidden field that will then be sent to a Google Sheet via Zapier. I have tried setting a default value for the hidden field as {date_updated:raw} or just date_updated:raw or even date_updated, none of which will populate the field upon edit. Are merge tags not the appropriate way to handle this? Unfortunately, Zaps cannot see the entry meta date updated or I would map it directly from there.

Any help would be greatly appreciated.

Hi Stephanie. Merge tags are not the way to handle this.

You can use GFAPI::update_entry_field to populate a field with the entry’s date and time of update:

You would want to call that after the entry is updated:

Then you need to run the zap after that to get the updated date to Zapier.

If you have any other questions, please let us know.

Thank you, Chris. I will test this out and come back if I have any questions.

Got it working, but have a couple of questions. Here is the code:

add_action( 'gform_after_update_entry_1', 'update_date_field', 10, 2 );
function update_date_field( $form, $entry_id ) {
	$date = date_i18n( 'Y-m-d H:i:s', $local_timestamp, true );
	#$date = rgar( $entry, 'date_updated' );
	#echo '<script type="text/javascript">console.log("Entry Date Updated is " + '.json_encode($date).');</script>';
	#GFCommon::log_debug( 'gform_after_update_entry: date_updated => ' . print_r( $date, 1 ) );
	$input_id = '212';
	GFAPI::update_entry_field( $entry_id, $input_id, $date );
}
  1. I couldn’t get it working using date_updated entry property (see commented $date - always returned null). I was hoping to use the entry object property of date_updated but realize it may use the known prior date_updated rather than the current date_updated from when I submit the edit. Am I wrong here?

  2. This is getting fed into a hidden field. However, the field could be edited by hand if the editor chose to when updating the entry. I know how to set a read only on a field but that would prevent the function from updating it (or would it?). How can I allow the function to update the field without also allowing manual changes when updating the entry?

Thanks again for the help!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.