Modify Display Value by Date

Experimental Snippet ๐Ÿงช

This experimental snippet allows you to modify the display value of a Date field if the current date is greater than the date saved in the given field.

For example, if today was May 23, 2022 and the field’s saved date was May 18, 2022, a “โœ”” would be displayed. For any date on or after May 23, 2022, the saved date would be displayed.

Screenshot: https://gwiz.io/3sRAgu4

Code

Filename: gpnf-modify-display-value-by-date.php

<?php
/**
 * Gravity Perks // Nested Forms // Modify Display Value by Date
 * https://gravitywiz.com/documentation/gravity-forms-nested-forms/
 *
 * Experimental Snippet ๐Ÿงช
 *
 * This experimental snippet allows you to modify the display value of a Date field if the current date is greater than
 * the date saved in the given field.
 *
 * For example, if today was May 23, 2022 and the field's saved date was May 18, 2022, a "โœ”" would be displayed. For any
 * date on or after May 23, 2022, the saved date would be displayed.
 *
 * Screenshot: https://gwiz.io/3sRAgu4
 */
// Update "123" to your child form ID and "4" to your child field ID.
add_filter( 'gpnf_display_value_123_4', function( $value, $field, $form, $entry ) {
	if ( strtotime( 'midnight' ) < strtotime( 'midnight', strtotime( rgar( $entry, $field->id ) ) ) ) {
		$value['label'] = 'โœ”';
	}
	return $value;
}, 10, 4 );

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.