Calendar: Developer Hooks
Note: The PHP examples on this page go in your site’s code. See Where to put code samples. For every GravityCalendar hook, with its parameters and where it is in the code, see GravityCalendar on gravitykit.dev.
Plugin paths #
gravityview/calendar/scripts/fullcalendar
Modify the FullCalendar core script used.
| Parameter | Type | Default | Description |
|---|---|---|---|
$path | string | {URL of plugin directory}/lib/fullcalendar/main.min.js (main.js when SCRIPT_DEBUG is on) | Full URL to the FullCalendar script. |
gravityview/calendar/scripts/fullcalendar/locales_dir_url
This filter is deprecated: the calendar no longer loads FullCalendar locale files. A callback on the filter still runs, but nothing uses the URL it returns. To change the calendar’s language, see Override the calendar language below.
| Parameter | Type | Default | Description |
|---|---|---|---|
$locales_url
|
string
|
{URL of plugin directory}/lib/fullcalendar/locales/
|
Not used. GravityCalendar no longer includes this folder. |
FullCalendar overrides #
gravityview/calendar/options
Modify all FullCalendar options in an array.
| Parameter | Type | Default | Description |
|---|---|---|---|
$calendar_options
|
array
|
Array of settings used when rendering FullCalendar | |
$form_id
|
int
|
Current form ID | The ID of the form connected to the calendar |
$feed_id
|
int
|
Current feed ID | The ID of the calendar feed currently being shown |
Override the calendar language
The calendar’s language is the feed’s Localization setting, in its Calendar Settings section. A new feed starts at the site’s language when the calendar supports it, and at English otherwise. The gravityview/calendar/default_locale filter changes that starting value: it receives a language code such as en or de and returns the one to use.
To set the language in code instead, change locale in gravityview/calendar/options. The month title, the dates, and the calendar’s own text follow it. The toolbar buttons keep the Localization language unless the same filter also sets buttonText, as in this example for French:
add_filter( 'gravityview/calendar/options', function ( $calendar_options, $form_id, $feed_id ) {
$calendar_options['locale'] = 'fr';
// The toolbar labels follow the feed's Localization setting, so set them as well.
$calendar_options['buttonText'] = array_merge( (array) ( $calendar_options['buttonText'] ?? [] ), [
'today' => "Aujourd'hui",
'dayGridMonth' => 'Mois',
'timeGridWeek' => 'Semaine',
'timeGridDay' => 'Jour',
] );
return $calendar_options;
}, 10, 3 );The keys in buttonText are the toolbar’s view names. A calendar that shows other views, such as listWeek, needs a key for each of them.
Display events as a full-width block
On the grid layout, set eventDisplay to block to show each event as a full-width block with a background color:
add_filter( 'gravityview/calendar/options', function ( $calendar_options, $form_id, $feed_id ) {
$calendar_options['eventDisplay'] = 'block';
return $calendar_options;
}, 10, 3 );Hiding days from other months (showNonCurrentDates)
Here’s an example of modifying the GravityCalendar output to disable showNonCurrentDates, but only for calendar feed #5:
add_filter( 'gravityview/calendar/options', function ( $calendar_options, $form_id, $feed_id ) {
// Only modify the setting for Calendar #5
if( 5 !== $feed_id ) {
return $calendar_options;
}
$calendar_options['showNonCurrentDates'] = false;
return $calendar_options;
}, 10, 3 );Showing times with two-digit minutes
The FullCalendar script displays times in a truncated manner on the month grid view. If you want to force times to be displayed with a 2-digit minute, you can with the filter below.
FullCalendar’s date formatting reference lists every option.
add_filter('gravityview/calendar/options', function ($calendar_options, $form_id, $feed_id ) {
$calendar_options['eventTimeFormat'] = [
'hour' => 'numeric',
'minute' => '2-digit',
'meridiem' => 'short'
];
return $calendar_options;
}, 10, 3 );Limiting the Agenda layouts to working hours on weekdays
The Week (Agenda) and Day (Agenda) layouts show all 24 hours, and the week shows all seven days. This code shows 8am to 8pm, Monday to Friday, in both Agenda layouts of one calendar. Replace 5 with the calendar’s ID, shown in the ID column on the All Calendars screen.
/**
* Shows 8am to 8pm, Monday to Friday, in the Agenda layouts of calendar 5.
*
* @param array $calendar_options FullCalendar options.
* @param int $form_id ID of the form the calendar uses.
* @param int $feed_id ID of the calendar.
*
* @return array FullCalendar options.
*/
add_filter( 'gravityview/calendar/options', function ( $calendar_options, $form_id, $feed_id ) {
if ( 5 !== $feed_id ) {
return $calendar_options;
}
$calendar_options['views']['timeGrid']['slotMinTime'] = '08:00:00';
$calendar_options['views']['timeGrid']['slotMaxTime'] = '20:00:00';
$calendar_options['views']['timeGrid']['weekends'] = false;
return $calendar_options;
}, 10, 3 );Events outside those hours, and events on Saturday and Sunday, don’t appear in the Agenda layouts. The other layouts still show them.
gravityview/calendar/extra_options
Modify extra options used in the plugin’s UI that aren’t standard to FullCalendar.
This is a way to pass additional data to the FullCalendar configuration object in a way that won’t affect initialization. For example, navigateToEvents is a custom calendar option and will throw an error if used to initialize a FullCalendar instance in the UI.
You can use it for similar reasons. For an example, see GravityCalendar event tooltips: what they show and how to change them, which uses it to turn off the event tooltip and to change where it opens.
Rendering & content overrides #
gravityview/calendar/settings/entry_status
Modify the status used to find matching entries. If set to false, no status will be defined, and all entries will be returned.
| Parameter | Type | Default | Description |
|---|---|---|---|
$status
|
string, false
|
'active'
|
Gravity Forms entry status. Options: 'active', 'spam', 'trash', or false
|
gravityview/calendar/settings/sort_order
| Parameter | Type | Default | Description |
|---|---|---|---|
$sort_order
|
array
|
[ 'key' => {sort field}, 'direction' => {sort order} ]
|
Sort order with key and direction values. They come from the feed’s sort settings; with none saved, the start date field in ascending order.
|
$feed_id
|
int
|
Current feed ID | ID of the current feed being processed |
$field_map
|
array
|
The feed’s field map | Gravity Forms field map array of feed fields mapped to calendar settings (e.g., start_time, end_time) |
/**
* Overrides the sort order to be sorted by form field #3 when using Calendar #22
*/
add_filter( 'gravityview/calendar/settings/sort_order', function ( $sort_order, $feed_id, $field_map ) {
if( 22 !== $feed_id ) {
return $sort_order;
}
return array(
'key' => 3,
'direction' => 'DESC',
);
}, 10, 3 );gravityview/calendar/events/source_data
This filter supplies the entries the calendar shows in place of the form’s entries. When it returns any entries, the calendar shows only those and doesn’t read the form.
Note: $from_date and $to_date values are created with strtotime() from Start Date and End Date field values. They are false if there was an error parsing the value when creating the timestamp.
| Parameter | Type | Default | Description |
|---|---|---|---|
$entries
|
array
|
[]
|
Entries for the calendar, each shaped like a Gravity Forms entry, with its values under the field IDs the calendar’s settings use. Empty unless another callback added some. |
$feed_id
|
int
|
0
|
ID of the current feed being processed |
$from_date
|
int, false, null
|
null
|
Start date timestamp used to filter events. |
$to_date
|
int, false, null
|
null
|
End date timestamp used to filter events. |
Example: show an event that isn’t stored in the form
/**
* Adds an event to calendar 5 that isn't stored as an entry.
*
* @param array $entries Entries for the calendar. Empty unless another callback added some.
* @param int $feed_id ID of the calendar.
* @param int|false|null $from_date Start of the dates shown, as a timestamp.
* @param int|false|null $to_date End of the dates shown, as a timestamp.
*
* @return array Entries for the calendar, each shaped like a Gravity Forms entry.
*/
add_filter( 'gravityview/calendar/events/source_data', function ( $entries, $feed_id, $from_date, $to_date ) {
if ( 5 !== (int) $feed_id ) {
return $entries;
}
$entries[] = [
'id' => 9001,
'form_id' => 4,
'1' => 'Cello, advanced', // Field 1, used in the calendar's Event Title.
'2' => '2026-10-20', // Field 2, the calendar's Start Date.
'3' => '10:30', // Field 3, the calendar's Start Time.
'4' => '12:30', // Field 4, the calendar's End Time.
];
return $entries;
}, 10, 4 );Each entry holds its values under the field IDs that the calendar’s settings use. In this example, the calendar’s Start Date is field 2, its Start Time is field 3, its End Time is field 4, and its Event Title is {Lesson:1}. Replace 5 with the calendar’s ID and the field IDs with your own. An array with keys such as title and start shows no event.
gravityview/calendar/events/exclude
Prevent entries from being displayed in the calendar by returning an array of IDs.
Note: An entry ID in this list is hidden even if it is also on the include list (see the gravityview/calendar/events/include filter).
| Parameter | Type | Default | Description |
|---|---|---|---|
$entry_ids | array | [] | Entry IDs to hide. It starts empty; return the IDs of the entries the calendar should leave out. |
$form | array | Current form | Gravity Forms form object connected to the calendar feed |
$feed | array | Current feed | Calendar Gravity Forms feed object |
$field_map | array | The feed’s field map | Gravity Forms field map array of feed fields mapped to calendar settings (e.g., start_time, end_time) |
$entries | array | [] or array[] | The full entries the calendar fetched. |
gravityview/calendar/events/include
Show these events in the calendar.
| Parameter | Type | Default | Description |
|---|---|---|---|
$entry_ids | array | The IDs of the entries the calendar fetched | Entry IDs to show. Return fewer IDs to show fewer events. |
$form | array | Current form | Gravity Forms form object connected to the calendar feed |
$feed | array | Current feed | Calendar Gravity Forms feed object |
$field_map | array | The feed’s field map | Gravity Forms field map array of feed fields mapped to calendar settings (e.g., start_time, end_time) |
$entries | array | [] or array[] | The full entries the calendar fetched. |
gravityview/calendar/events/do_shortcodes
Modify whether to process shortcodes in the event title and event description.
| Parameter | Type | Default | Description |
|---|---|---|---|
$do_shortcode | bool | true | Whether to process shortcodes in the event title and description. |
$form | array | Current form | Gravity Forms form object connected to the calendar feed |
$feed | array | Current feed | Calendar Gravity Forms feed object |
$field_map | array | The feed’s field map | Gravity Forms field map array of feed fields mapped to calendar settings (e.g., start_time, end_time) |
gravityview/calendar/shortcode/render/element_attributes
| Parameter | Type | Default | Description |
|---|---|---|---|
$attributes
|
array
|
See below | Array of HTML attributes to be applied to the calendar container |
| Key | Type | Default | Description |
|---|---|---|---|
class | string | gv-fullcalendar | CSS class for the container |
data-feed_id | int | $feed_id | The ID of the feed being rendered. |
data-calendar_id | string | wp_generate_password() | Simple hash to differentiate multiple calendars. |
data-view_id | int | $view_id | The ID of the View the calendar is embedded in, or 0 outside a View. |
data-height | string | The embed’s height, or the feed’s Height when Sizing is Fixed, otherwise auto | Height of the calendar for this embed. |
id | string | gv-calendar-{View ID}-{feed ID} | Set only when the calendar is inside a View. |
data-gv-morph | string | keep | Set only inside a View, so the calendar stays in place when GravityView refreshes the View. |
Feed setting filters #
gravityview/calendar/settings/total-event-limit
Modify the total number of events displayed on a calendar. Events from the form’s entries have no limit by default. Events supplied through gravityview/calendar/events/source_data are limited to 1000. Return 0 or less for no limit.
| Parameter | Type | Default | Description |
|---|---|---|---|
$total_event_limit
|
int
|
0 for entries, 1000 for source_data events
|
Maximum total number of events to fetch. 0 or less means no limit.
|
$feed_id
|
int
|
Current feed ID | The ID of the calendar feed currently being shown |
gravityview/calendar/settings/fields/date
Override the field types shown in the feed configuration when selecting Start Date and End Date.
| Parameter | Type | Default | Description |
|---|---|---|---|
$field_types
|
array
|
['date', 'date_created', 'date_updated', 'event']
|
Default field types used for populating the Start Date or End Date settings. |
Allow for text fields to be used in the feed configuration
If you allow entering dates into a text field (not recommended, because the formatting varies), you can use that field as the Start Date or End Date. The code below allows that:
/**
* Add Text fields to the list of fields to display when selecting Start Date and End Date.
*
* @param array $field_types
*
* @return array Field types, with "text" added.
*/
add_filter( 'gravityview/calendar/settings/fields/date', function ( $field_types ) {
$field_types[] = 'text';
return $field_types;
} );gravityview/calendar/settings/fields/time
Override the field types shown in the feed configuration when selecting Start Time and End Time.
| Parameter | Type | Default | Description |
|---|---|---|---|
$field_types
|
array
|
['time', 'date_created_time', 'date_updated_time', 'event']
|
Default field types used for populating the Start Time or End Time settings. |
gravityview/calendar/settings/fields/location
Override the field types shown in the feed configuration when selecting Event Location.
| Parameter | Type | Default | Description |
|---|---|---|---|
$field_types
|
array
|
['address']
|
Default field types used for populating the Event Location setting. |
gravityview/calendar/settings/fields/url
Override the field types shown in the feed configuration when selecting Event URL.
| Parameter | Type | Default | Description |
|---|---|---|---|
$field_types
|
array
|
['url', 'website']
|
Default field types used for populating the Event URL setting. |
Calendar subscription cache filters #
Subscription calendars (the .ics feed that calendar apps poll) are generated once, stored, and served from that stored copy. The copy is rebuilt when it expires, when the feed is saved, and when entries are added, edited, or deleted. These filters control that behavior.
gk/gravitycalendar/ics-export/cache/enabled
Whether generated subscription calendars are stored and served from the stored copy. Return false to generate the calendar on every request, site-wide or for one feed.
bool $enabledWhether the generated calendar may be stored. Defaulttrueint $feed_idThe feed being generated
gk/gravitycalendar/ics-export/cache/lifetime
How long a stored subscription calendar is served before it is rebuilt.
int $lifetimeSeconds. Default3600(one hour)int $feed_idThe feed ID
gk/gravitycalendar/ics-export/cache/rebuild-timeout
How long a rebuild may run before its claim is considered abandoned and another request is allowed to rebuild the calendar.
int $secondsTimeout in seconds. Default600(ten minutes)int $feed_idThe feed ID
Example: serve feed 12 fresh on every request, and keep every other feed’s stored copy for 15 minutes instead of an hour.
add_filter( 'gk/gravitycalendar/ics-export/cache/enabled', function ( $enabled, $feed_id ) {
return 12 === $feed_id ? false : $enabled;
}, 10, 2 );
add_filter( 'gk/gravitycalendar/ics-export/cache/lifetime', function ( $lifetime, $feed_id ) {
return 15 * MINUTE_IN_SECONDS;
}, 10, 2 );