Hi @salgraphics
I hope you are doing well.
I made a couple of tests on my lab site and I believe with a small code we can help you here.
Could you give it a try at
– Add a hidden field, select “Custom value” and use {custom_day_value} as the default value:
https://monosnap.com/file/XjDaLNusGK6AFqie9Q42m0pHkSmaGN
– We will update the value depending on the day of the month example 35 or 40 in your case,
– So you can use it to make any calculation or visibility rule:
https://monosnap.com/file/1L4DGSWN7VH9ERwIKaCyPXRZMpOkl7
For this, add this code as a mu-plugin:
<?php
add_action('forminator_custom_form_submit_before_set_fields', 'wpmudev_change_hidden_field_custom', 10, 3);
function wpmudev_change_hidden_field_custom($entry, $module_id, $field_data_array)
{
$form_ids = array(6); // Please change the form ID.
if (!in_array($module_id, $form_ids)) {
return;
}
foreach ($field_data_array as $key => $value) {
if (strpos($value['name'], 'hidden-1') !== false) {
Forminator_CForm_Front_Action::$info['field_data_array'][$key]['value'] = sanitize_text_field(Forminator_CForm_Front_Action::$prepared_data['hidden-1']);
}
}
}
add_filter('forminator_field_hidden_field_value', 'wpmudev_populate_hidden_field_date', 10, 4);
function wpmudev_populate_hidden_field_date($value, $saved_value, $field, $hidden_field)
{
if ('custom_value' == $saved_value && '{custom_day_value}' == $value) {
//get a current day of the month
$date = strtotime(date("m/dY"));
// Check if the current day is less than 6th day of the month
if (date("d", $date) <= 6) {
$prepared_data['hidden-1'] = 35; // change the value of hidden field
} else {
$prepared_data['hidden-1'] = 40; // change the value of hidden field
}
}
return $value;
}
Replace the form ID where it says “Please change the form ID”,
Update the “hidden-1” in the code in case it is a different hidden ID.
https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins
Now it will add the 40 or 35 as a value for the hidden field dynamically depending on the day.
Let us know if it helps you
Best Regards
Patrick Freitas