Skip to content

Triggered events

This plugin triggers several events to allow greater customization for developers:

Craft CMS has a tutorial on wiring up your first event handler in a module.

Events

Register types

Event triggered when registering types of events.

Event::on(
    Events::class,
    Events::EVENT_REGISTER_TYPES,
    function (RegisterEventTypesEvent $e) {
        $e->types[] = Meeting::class;
    }
);

Register sources

Event triggered when registering event sources. The built-in types for entries and products will register an event source for each entry type and product type that has an event date field.

Event::on(
    Events::class,
    Events::EVENT_REGISTER_SOURCES,
    function (RegisterEventSourcesEvent $e) {
        foreach ($e->sources as $key => $source) {
            if ($key === 'entry:meetings:meeting') {
                $source->color = Color::PISTACHIO->value;
            }
        }
    }
);

Define organizer query

Event triggered before querying the users listed in the organizer filter on the control panel calendar. By default the query returns the users in the configured organizer user group.

Event::on(
    Events::class,
    Events::EVENT_DEFINE_ORGANIZER_QUERY,
    function (DefineOrganizerQueryEvent $e) {
        $e->query->admin();
    }
);

Exporter

After build ICS

Event triggered after building the ICS object but before exporting the file.

Event::on(
    Exporter::class,
    Exporter::EVENT_AFTER_BUILD_ICS,
    function (AfterBuildIcsEvent $event) {
        $event->icsEvent->setUid($event->element->relatedEntry->uid);
    }
);

The organizer is noreply@ your site's hostname by default, named after the current site. To use a different organizer, replace it with setOrganizers():

Event::on(
    Exporter::class,
    Exporter::EVENT_AFTER_BUILD_ICS,
    function (AfterBuildIcsEvent $event) {
        $event->icsEvent->setOrganizers(['events@example.com' => 'Example Events']);
    }
);

Date helper

Define timezone label

Triggered when a timezone label is added to formatted times (e.g. with the displayTimezone setting), and for each option in the timezone dropdown of Event Date fields. The label defaults to the locale's short name for the timezone (e.g. "EST"), from the Unicode locale data (CLDR) in PHP's intl extension.

Use it when that name is wrong or out of date. For example, British Columbia stopped changing its clocks on November 1, 2026, but the locale data still calls its time "PDT":

Event::on(
    DateHelper::class,
    DateHelper::EVENT_DEFINE_TIMEZONE_LABEL,
    function (DefineTimezoneLabelEvent $event) {
        if (
            $event->timezone === 'America/Vancouver' &&
            $event->date >= new DateTime('2026-11-01 02:00', new DateTimeZone('America/Vancouver'))
        ) {
            $event->label = 'PCT';
        }
    }
);