Notification with add to calendar link

Hi All,
Is there an easy way to add a calendar link to customers’ email notifications based on a field?

The scenario of the form:

  1. The user selects a date for an appointment
  2. They click send, which sends back a notification and an email with a link for them to add the appointment to their calendar.

Thank you for your help.


You should be able to integrate your appointment form with Google Calendar with an appointment add-on.

Here are a couple of add-ons you can check with this functionality:

Hi Juan,
Thank you for your reply


These add-ons seem like a more elaborate calendar functionality and it does not meet the function that I am after.

All I wanted to do was have the notifications email also have a calendar link that the user can click and add to their calendar on their computer.

Something similar to the following but also embedded in the customer notification email.

Figure: Add appointment to your calendar


There is actually a way to achieve what you have described.

To create an ‘Add to Calendar’ link for Google Calendar, you can leverage the following link structure:{YOUR_EVENT_TITLE}&dates={START_DATE/END_DATE}&details={DESCRIPTION}&location={LOCATION}

You can provide:

  1. An event title.
  2. A start and end date. Date and Time.
  3. A description.
  4. A location.

And you can build the URL in the Notification message body.

You can feed the variables in the form manually by entering the details or dynamically from the form fields.

The challenge here is with the date field. The format is mm/dd/yyyy.

Google Calendar needs a specific date format in the URL, or the ‘Add to Calendar’ won’t work.

To solve this, you need to intercept the date selected by the user in the form’s date field, store it, and pass it to the URL in the notification.

You need:

  1. A hidden field.
  2. A script that will process the value in the Date field and store it in the right format on the hidden field.
  3. Pass the hidden field value to the URL in the Notification message body.

Once you add the hidden field, take note of the field’s ID.

Also, take note of the Date field ID.

Please see the snippet to process the date below:

add_action('gform_pre_submission', 'format_date_for_google_calendar');
function format_date_for_google_calendar($form) {
    // This is an array. This supports multiple forms, comma-separated.
    $target_form_ids = [FORM_ID]; // Replace FORM_ID with your form ID.

    // Check if the current form's ID is in the target form IDs array
    if (!in_array($form['id'], $target_form_ids)) {
        return; // Exit if it's not one of the targeted forms

    foreach ($form['fields'] as &$field) {
        if ($field->type != 'date' || $field->id != DATE_FIELD_ID) continue;

        $date_value = rgpost('input_' . $field->id);

        // Determine the date format
        $date_format = strpos($date_value, '-') !== false ? 'Y-m-d' : 'm/d/Y';
        $date = DateTime::createFromFormat($date_format, $date_value);

        if ($date === false) {
            error_log('Failed to parse date: ' . $date_value);

        // Format the date for Google Calendar
        $start_date = $date->format('Ymd\THis\Z');
        $date->modify('+1 hour'); //Define the meeting duration. Change to match your needs.
        $end_date = $date->format('Ymd\THis\Z');

        // Update the hidden field with the formatted date
        $_POST['input_' . HIDDEN_FIELD_ID] = $start_date . '/' . $end_date;

In the code above, make sure to replace FORM_ID, DATE_FIELD_ID, and HIDDEN_FIELD_ID.

In the Notification message body, you can reference the value of specific fields like this: {field_id:ID_NUMBER}.

Saying your hidden field’s ID is 5, it would be {field_id:5}.

Then, you can create a link with the Insert Link option in the editor.


Make sure to replace {START_DATE/END_DATE} with your {field_id:ID_NUMBER} in the URL, like so:{YOUR_EVENT_TITLE}&dates={field_id:ID_NUMBER}&details={DESCRIPTION}&location={LOCATION}

You can manually set the other variables or reference them dynamically from IDs in the form.

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