Need help populating hidden field with php echo date("l") [RESOLVED]

I’m trying to show other fields based on current day of the week. Use case is for specials in a menu order form only available certain days. I’m more css savvy and a fish out of water when it comes to writing php functions from scratch.

Here’s what I have in the form, I just need help understanding the connective tissue on the function side.

weekday

1 Like

+1 for connective tissue!

Now that the form is set up, add this PHP code to your theme functions.php or a custom functionality plugin if you use one:

add_filter( 'gform_field_value_weekday', 'populate_the_weekday' );
function populate_the_weekday( $value ) {
	$local_timestamp = GFCommon::get_local_timestamp( time() );
	return date_i18n( 'l', $local_timestamp, true );
}

That will put today’s date Thursday into your field.

1 Like

Added and running strong, thank you. Exactly what I needed.

1 Like

You’re welcome.