Gravity Forms + Gravity Flow Specific Date notice

We have a form in Gravity Forms, that a logged-in user fills out. There is a hidden field that is populated with the user_role of the user.

The form is sent to an admin for approval and they can change the field for user_role, to another role as they feel fit.

On a particular day of the year, every year (ex. September 1st) I am trying to send a notification from Gravity Flow to the user. I can schedule the notification, but it requires a year (ie. yyyy-mm-dd)

I was thinking I can try to use {today:format:Y}-09-01 in Gravity Flow. If merge tags would even work, it would not be relevant for months 10, 11, 12 since those would have the current year.

I was also thinking I could try to put a hidden date field in the Gravity Forms form. But I would still be in the same boat where if the user filled out the form in Oct, Nov, or Dec the year would be 2023, but I really want it to be 2024.

Anyone have an idea how I can set the notification to go out regardless of the year, or at least figure out how to send only on a specific date?

I think I got it with creating a custom merge tag. The logic seems to be right. I just put a hidden date field in the form and placed this tag {notice_tag} then scheduled the notice in Gravity Flow based on that date.

// Define a function to get the adjusted date
function custom_notice_tag_merge_tag($text, $form, $entry, $url_encode, $esc_html, $nl2br, $format) {
   // Get the current date
   $current_date = new DateTime();
   
   // Get the current month
   $current_month = intval($current_date->format('m'));

   // Define the target month and day
   $target_month = 9;
   $target_day = 1;

   // Check if the current month is in Jan to Sept (months 1 to 9)
   if ($current_month >= 1 && $current_month <= 9) {
       // Keep the current year, change the month and day
       $current_date->setDate($current_date->format('Y'), $target_month, $target_day);
   } else {
       // Increment the current year by 1, change the month and day
       $current_date->modify('+1 year');
       $current_date->setDate($current_date->format('Y'), $target_month, $target_day);
   }

   // Format the adjusted date as yyyy-mm-dd
   $adjusted_date = $current_date->format('Y-m-d');
   
   // Replace {notice_tag} with the adjusted date
   $text = str_replace('{notice_tag}', $adjusted_date, $text);

   return $text;
}

// Hook the custom function into Gravity Forms
add_filter('gform_replace_merge_tags', 'custom_notice_tag_merge_tag', 10, 7);

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