Would you like to extend or customize Sugar Calendar Events with your own code? Sugar Calendar Events includes action and filter hooks that let you add content, change data, and run code when things happen, such as when someone saves an event or completes a ticket order.
In this tutorial, we’ll show you how to use the hooks in Sugar Calendar Events and where to find the right one for your project.
In This Article
Before getting started, make sure Sugar Calendar Events is installed and activated on your WordPress site.
How to Use Hooks
Sugar Calendar Events has two kinds of hooks:
- Action hooks run your code at a specific point, for example, to output extra content on the event page. Attach code to them with
add_action(). - Filter hooks pass a value through your code so you can change it, for example, to change the From name on emails. Attach code to them with
add_filter(), and always return a value.
Add your code to a code snippets plugin or to your child theme’s functions.php file, so theme updates don’t remove it. For example, this snippet adds a line of text after the description on every single event page:
add_action( 'sc_after_event_content', function () {
echo '<p>Doors open 30 minutes before the start time.</p>';
} );
To learn more about how hooks work, see the WordPress guides to action hooks and filter hooks.
Single Event Pages
Use these hooks to change what visitors see on a single event page. The event details rows run on sugar_calendar_frontend_event_details at these priorities: date (20), time (30), location (40), link (45), and calendars (50). Choose a priority to place your own row between them.
| Hook | Type | Since | What it does |
|---|---|---|---|
sugar_calendar_frontend_event_details_before | Action | 3.1.0 | Fires before the event details box. Passes $event. |
sugar_calendar_frontend_event_details | Action | 3.1.0 | Outputs the event details rows. Hook in at a priority to add your own row. Passes $event. |
sugar_calendar_frontend_event_details_date | Action | 3.1.0 | Fires after Sugar Calendar Events outputs the event date. Passes $event. |
sugar_calendar_frontend_event_badges | Filter | 3.14.0 | Changes the badges shown above the event details, such as Featured. Passes $badges and $event. |
sugar_calendar_frontend_loader_event_object | Filter | 3.6.0 | Changes the event object used to build the event details. Passes $event. |
sc_before_event_content | Action | — | Fires before the event description. Passes $post_id. |
sc_after_event_content | Action | 1.0 | Fires after the event description. Passes $post_id and $event. |
sc_event_details | Action | 2.0.7 | Fires where Sugar Calendar Events adds the event details to the content. Passes $post_id. |
sc_event_content_hooks_event | Filter | 3.6.0 | Changes the event object before Sugar Calendar Events outputs the event content. Passes $event. |
sugar_calendar_get_single_event_appearance_mode | Filter | 3.3.0 | Changes the Event Page Appearance setting (light or dark). |
sugar_calendar_helpers_get_event_excerpt | Filter | 3.11.0 | Changes an event’s excerpt. Passes $excerpt and the post ID. |
sugar_calendar_helpers_get_event_content | Filter | 3.14.0 | Changes an event’s full description. Passes $content and the post ID. |
sugar_calendar_structured_data_enabled | Filter | 3.12.0 | Return false to stop Sugar Calendar Events from adding event structured data (JSON-LD) to the page. Passes $enabled and $event. |
sugar_calendar_structured_data_providers | Filter | 3.12.0 | Changes the list of structured data (schema) providers. |
Events Archive
When your theme has no archive-sc_event.php file, Sugar Calendar Events displays the events archive as a built-in Events page. To learn more, see our guide to customizing template files.
| Hook | Type | Since | What it does |
|---|---|---|---|
sugar_calendar_frontend_loader_virtual_post | Filter | 3.10.0 | Changes the built-in Events page, such as its title or the Event List shortcode it displays. Passes the page object. |
Calendar and Event List Blocks
These hooks change the Calendar and Event List blocks and their shortcodes.
| Hook | Type | Since | What it does |
|---|---|---|---|
sugar_calendar_block_calendar_view_month_events | Filter | 3.6.0 | Changes the events shown in the Calendar block’s month view. Passes the events, the date range, and the block’s calendars. |
sugar_calendar_block_common_abstract_block_get_week_events | Filter | 3.6.0 | Changes the events shown in the week view. |
sugar_calendar_block_calendar_view_day_events | Filter | 3.6.0 | Changes the events shown in the day view. |
sugar_calendar_block_common_abstract_block_get_max_events_count | Filter | 3.7.0 | Changes the maximum number of events a block loads. |
sugar_calendar_block_common_abstract_block_is_featured_only | Filter | 3.14.0 | Changes whether a block shows only featured events. Passes $featured_only and the block. |
sugar_calendar_block_popover_event_cta | Filter | 3.12.0 | Changes the call-to-action button in the Calendar block’s event popover. Passes $cta (label, link, and type), the post ID, and the event ID. |
sugar_calendar_block_calendar_loader_popover_image_size | Filter | 3.5.0 | Changes the image size in the Calendar block’s event popover. Default medium. |
sugar_calendar_block_list_gridview_image_size | Filter | 3.5.0 | Changes the image size in the Event List block’s grid view. Default medium. |
sugar_calendar_block_list_listview_image_size | Filter | 3.5.0 | Changes the image size in the Event List block’s list view. Default medium. |
sugar_calendar_block_event_list_event_list_view_event_view_dt_display | Filter | 3.7.0 | Changes the date and time text in the Event List block. Passes the text, $event, the date, and the time format. |
sugar_calendar_blocks_get_visitor_timezone | Filter | 3.1.2 | Changes the visitor time zone used to convert event times. |
sugar_calendar_block_show_venue_filter | Filter | 3.5.0 | Return false to hide the venue filter in blocks. (Pro) |
sugar_calendar_features_tags_frontend_blocks_show_tags_filter | Filter | 3.7.0 | Return false to hide the tag filter in blocks. |
sugar_calendar_pro_features_speakers_frontend_blocks_show_speaker_filter | Filter | 3.7.0 | Return false to hide the speaker filter in blocks. (Pro) |
sugar_calendar_block_popover_additional_filters | Action | 3.5.0 | Fires after the calendars filter in the Calendar block’s filter popover, so you can add your own filter controls. |
Event Data and Queries
Use these hooks to change how events are queried, or to run code when events are saved.
| Hook | Type | Since | What it does |
|---|---|---|---|
sugar_calendar_get_events_args | Filter | 3.6.0 | Changes the arguments used to query events. |
sugar_calendar_added_event | Action | 3.6.0 | Fires after Sugar Calendar Events adds an event. Passes the event ID and the saved data. |
sugar_calendar_updated_event | Action | 3.6.0 | Fires after Sugar Calendar Events updates an event. Passes the event ID, the saved data, and the event before the update. |
sugar_calendar_event_duplicated | Action | 3.11.0 | Fires after Sugar Calendar Events duplicates an event. Passes the new and original event IDs and post IDs. (Pro) |
sugar_calendar_event_construct | Filter | 2.2.0 | Changes an event object as Sugar Calendar Events creates it. |
sugar_calendar_meta_data | Filter | 3.4.0 | Changes the event meta data schema, so you can register your own event fields. |
sugar_calendar_exclude_ghost_events | Filter | 3.11.0 | Changes whether queries skip events whose post no longer exists. Default true. |
Post Types and Taxonomies
These filters change how Sugar Calendar Events registers its post types and taxonomies. To change the Calendars taxonomy, use the WordPress register_taxonomy_args filter for sc_event_category.
| Hook | Type | Since | What it does |
|---|---|---|---|
sc_event_labels | Filter | 2.0.0 | Changes the labels of the Events post type. |
sc_event_supports | Filter | — | Changes the features the Events post type supports, such as thumbnail or comments. |
sc_event_rewrite | Filter | — | Changes the rewrite settings of the Events post type. To change the slug, see our guide to updating the event slug. |
sc_event_capability_type | Filter | — | Changes the capability types of the Events and Venues post types. |
sugar_calendar_tags_taxonomy_labels | Filter | 3.7.0 | Changes the labels of the Tags taxonomy. |
sugar_calendar_tags_taxonomy_slug | Filter | 3.7.0 | Changes the slug of the Tags taxonomy. |
sugar_calendar_tags_taxonomy_rewrite | Filter | 3.7.0 | Changes the rewrite settings of the Tags taxonomy. |
sc_venue_labels | Filter | 3.5.0 | Changes the labels of the Venues post type. (Pro) |
sc_venue_rewrite | Filter | 3.5.0 | Changes the rewrite settings of the Venues post type. (Pro) |
sugarcalendar_venue_supports | Filter | 3.5.0 | Changes the features the Venues post type supports. (Pro) |
sc_speakers_post_type_slug | Filter | 3.7.0 | Changes the slug of the Speakers post type. (Pro) |
sc_speakers_post_type_supports | Filter | 3.7.0 | Changes the features the Speakers post type supports. (Pro) |
Venues, Speakers, and Maps
Use these hooks to change single venue and speaker pages, and the address and coordinates sent to Google Maps.
| Hook | Type | Since | What it does |
|---|---|---|---|
sc_venue_details_before | Action | 3.5.0 | Fires before the details on a single venue page. Passes $venue_data. (Pro) |
sc_venue_details | Action | 3.5.0 | Outputs the details on a single venue page. Passes $venue_data. (Pro) |
sc_venue_details_after | Action | 3.5.0 | Fires after the details on a single venue page. Passes $venue_data. (Pro) |
sugarcalendar_venue_supported_countries | Filter | 3.5.0 | Changes the list of countries available for venue addresses. (Pro) |
sc_speaker_details_before | Action | 3.7.0 | Fires before the details on a single speaker page. Passes $speaker_data. (Pro) |
sc_speaker_details | Action | 3.7.0 | Outputs the details on a single speaker page. Passes $speaker_data. (Pro) |
sc_speaker_details_after | Action | 3.7.0 | Fires after the details on a single speaker page. Passes $speaker_data. (Pro) |
sc_speaker_details_social_links | Filter | 3.7.0 | Changes a speaker’s social links. (Pro) |
sugar_calendar_common_features_google_maps_feature_address | Filter | 3.10.0 | Changes the address sent to Google Maps. Passes $address and $event. |
sugar_calendar_common_features_google_maps_feature_coordinates | Filter | 3.5.0 | Changes the map coordinates for an event. Passes $coordinates and the event ID. |
Emails
These hooks apply to the emails Sugar Calendar Events sends, such as ticket receipts and registration emails.
| Hook | Type | Since | What it does |
|---|---|---|---|
sc_email_from_name | Filter | 1.0.0 | Changes the email From name. |
sc_email_from_address | Filter | 1.0.0 | Changes the email From address. |
sc_email_headers | Filter | 1.0.0 | Changes the email headers. |
sc_email_attachments | Filter | 1.0 | Changes the email attachments. |
sc_email_message | Filter | 1.0.0 | Changes the email message content. |
sc_email_footer_text | Filter | 1.0 | Changes the email footer text. |
sc_email_tags | Filter | 1.0 | Adds or changes the Smart Tags available in emails. |
sc_email_send_before | Action | 1.0 | Fires before Sugar Calendar Events sends an email. |
sc_email_send_after | Action | 1.0 | Fires after Sugar Calendar Events sends an email. |
sugar_calendar_emails_styling | Filter | 3.14.0 | Changes the Email Styling values, such as colors and the header image. |
sugar_calendar_emails_calendar_url | Filter | 3.14.0 | Changes the Add to Calendar link in emails. Passes the URL and the email context. |
sugar_calendar_admin_notification_recipient | Filter | 3.14.0 | Changes who receives admin notification emails. Default is the site admin email. Passes the address and the email ID. |
Event Ticketing
Use these hooks to customize ticket checkout, orders, and the ticket form. To learn more about tickets, see our Event Ticketing guide.
| Hook | Type | Since | What it does |
|---|---|---|---|
sc_et_checkout_complete | Action | 3.12.0 | Fires once after Sugar Calendar Events fully saves a ticket order, including its tickets and attendees. Passes the order details and $order_id. |
sc_et_checkout_complete_payload | Filter | 3.12.0 | Changes the order details passed to sc_et_checkout_complete. |
sc_et_order_{$new_status} | Action | 3.12.0 | Fires when an existing order changes status, such as sc_et_order_refunded. Passes the order details, $order_id, and the old status. |
sc_et_order_status_actions | Filter | 3.12.0 | Changes which statuses fire sc_et_order_{$new_status}. Default paid, pending, refunded, and trash. |
sugar_calendar_ticketing_order_deleted | Action | 3.13.0 | Fires after Sugar Calendar Events deletes an order and its data. Passes $order_id. |
sc_et_checkout_validate_data | Action | 3.6.0 | Fires while Sugar Calendar Events validates checkout data, so you can add your own checks. |
sc_et_success_page_url | Filter | — | Changes the page visitors go to after a successful checkout. |
sc_et_should_display_tickets | Filter | 3.2.0 | Changes whether tickets display for an event. Passes the value and $event. |
sc_et_purchase_button_html | Filter | 1.1.0 | Changes the ticket purchase button HTML. Passes the HTML and $event. |
sc_event_tickets_form_top | Action | 3.8.0 | Fires at the top of the ticket form. Passes $event and the post ID. |
sc_event_tickets_form_bottom | Action | 1.0.0 | Fires at the bottom of the ticket form. Passes $event and the post ID. |
sc_et_modal_attendee_fields_after | Action | 3.8.0 | Fires after the attendee fields in the checkout window. Passes $event. |
sc_et_modal_form_bottom | Action | 3.6.0 | Fires before the end of the checkout form. Passes $event. |
sc_et_currencies | Filter | 1.0.0 | Changes the list of supported currencies. |
sc_et_currency | Filter | 1.0.0 | Changes the store currency. |
sc_et_format_amount | Filter | 1.0.0 | Changes how prices are formatted. |
sc_et_stripe_statement_descriptor | Filter | 3.3.0 | Changes the text on customers’ card statements. Default Event Tickets. |
sc_event_tickets_list_table_columns | Filter | 1.0.0 | Changes the columns in the admin orders table. |
sc_et_export_capability | Filter | 1.0.0 | Changes the capability needed to export orders and attendees. |
sugar_calendar_ticketing_use_legacy_receipt | Filter | 3.14.0 | Return true to show the older table-style receipt instead of the card. |
sugar_calendar_ticketing_use_legacy_details | Filter | 3.14.0 | Return true to show the older table-style ticket details instead of the card. |
Registration Forms
These filters change how event registration forms work. To learn more, see our guide to creating a registration form.
| Hook | Type | Since | What it does |
|---|---|---|---|
sugar_calendar_registration_form_max_attendees | Filter | 3.13.0 | Changes the maximum number of attendees per submission. Default 100. (Pro) |
sugar_calendar_registration_reminders_enabled | Filter | 3.13.0 | Return false to stop reminder emails for unfinished registrations. (Pro) |
sugar_calendar_registration_reminder_threshold | Filter | 3.13.0 | Changes how long, in seconds, an unfinished registration waits before a reminder. Default one hour. (Pro) |
sugar_calendar_registration_rate_limiter_enabled | Filter | 3.13.0 | Return false to turn off the registration rate limiter. (Pro) |
sugar_calendar_registration_rate_limiter_limit | Filter | 3.13.0 | Changes how many registration attempts a visitor can make per time window. (Pro) |
sugar_calendar_registration_rate_limiter_client_ip | Filter | 3.13.0 | Changes the visitor IP the rate limiter uses, for example, behind a proxy. Default REMOTE_ADDR. (Pro) |
Calendar Feeds, Import, and Export
Use these hooks to change calendar feeds and Add to Calendar links, and to run code during imports and exports.
| Hook | Type | Since | What it does |
|---|---|---|---|
sugar_calendar_calendar_feeds_events | Filter | 3.11.0 | Changes the events included in calendar feeds. (Pro) |
sugar_calendar_pro_features_calendar_feeds_helpers_links | Filter | 3.10.0 | Changes the Add to Calendar links on events. Passes the links and $event. (Pro) |
sugar_calendar_ics_sync_fetch_timeout | Filter | 3.13.0 | Changes the time limit, in seconds, for fetching scheduled ICS imports. Default 30. (Pro) |
sugar_calendar_pro_importer_ics_event_data | Filter | 3.6.0 | Changes each event’s data during an ICS import. (Pro) |
sugar_calendar_importer_started | Action | 3.15.0 | Fires when an import starts. Passes the source: tec, json, or ics. |
sugar_calendar_importer_completed | Action | 3.15.0 | Fires when an import finishes. Passes the source and the number of events imported. |
sc_import_tec_events_limit | Filter | 3.3.0 | Changes how many events from The Events Calendar import per batch. Default 10. |
sugar_calendar_admin_tools_export_csv_event_columns | Filter | 3.13.0 | Adds or changes columns in the events CSV export. |
Admin Area
Use these hooks to add your own fields to the event editor, change admin permissions, and customize the admin events list.
| Hook | Type | Since | What it does |
|---|---|---|---|
sugar_calendar_admin_meta_box_setup_sections | Action | 3.0.0 | Fires when the event settings box registers its tabs. Call $metabox->add_section() with an id, label, icon, order, and callback to add your own tab. |
sugar_calendar_admin_meta_box_sections | Filter | 3.0.0 | Changes the tabs in the event settings box. |
sc_event_meta_box_before | Action | 3.0.0 | Outputs table rows in an Other tab of the event settings box. The tab only appears when your code uses this hook. |
sc_event_meta_box_after | Action | 3.0.0 | Outputs table rows at the end of the Other tab. |
sugar_calendar_get_capability_manage_options | Filter | 3.0.0 | Changes the capability needed to manage Sugar Calendar Events settings. Default manage_options. |
sugar_calendar_admin_area_capability | Filter | 3.0.1 | Changes the capability needed to see the Events menu. Default edit_events. |
sugar_calendar_manage_sc_event_posts_columns | Filter | 3.12.0 | Adds or changes columns in the admin events list. |
sugar_calendar_admin_events_tables_base_{$column_name}_contents | Filter | 3.0.0 | Changes the contents of a column in the admin events list. |
sugar_calendar_admin_pages_settings_get_tabs | Filter | 3.0.0 | Adds or changes the tabs on the Events » Settings page. |
sugar_calendar_admin_flyout_menu | Filter | 3.9.0 | Return false to hide the quick links menu in the admin. |
Integrations and AI
Use these hooks to respond to integration connections, change Zoom and Google Meet meetings, control Google Calendar syncing, and control the AI features.
| Hook | Type | Since | What it does |
|---|---|---|---|
sugar_calendar_integration_connected | Action | 3.15.0 | Fires after an integration connects or reconnects. Passes the provider slug, such as zoom. |
sugar_calendar_integration_disconnected | Action | 3.15.0 | Fires after an integration disconnects. Passes the provider slug. |
sugar_calendar_zoom_meeting_settings | Filter | 3.12.0 | Changes the settings Sugar Calendar Events sends to Zoom when it creates a meeting. Passes $settings and $event. |
sugar_calendar_zoom_webhook_event_{$event_type} | Action | 3.12.0 | Fires after Sugar Calendar Events handles a Zoom webhook event. Passes the webhook payload. |
sugar_calendar_online_meeting_changed | Action | 3.16.0 | Fires after an event’s online meeting is created, removed, or switched in the event editor. Passes the event. |
sugar_calendar_integrations_before_disable | Action | 3.16.0 | Fires before Sugar Calendar Events Lite deletes its stored connections when Disable Integrations is turned on. |
sugar_calendar_google_calendar_mapping | Filter | 3.16.0 | Maps Google calendars to Sugar Calendar calendars, each with its own sync direction. Replaces the calendar and direction saved on the Integrations tab. |
sugar_calendar_google_pull_window_days | Filter | 3.16.0 | Sets how many days ahead the first Google sync imports existing events. Defaults to 0 (none). Use -1 for no limit. |
sugar_calendar_google_pull_event_status | Filter | 3.16.0 | Changes the post status of events created from Google Calendar. Defaults to publish. |
sugar_calendar_google_pull_event_data | Filter | 3.16.0 | Changes the event data from a Google event before Sugar Calendar Events saves it. Passes $data and the Google event. |
sugar_calendar_google_pulled_event | Action | 3.16.0 | Fires after a Google event is saved in Sugar Calendar Events. Passes the event ID and the saved data. |
sugar_calendar_google_description_map | Filter | 3.16.0 | Changes the rewrites applied to an event description before it’s sent to Google Calendar. |
sugar_calendar_google_description_tags | Filter | 3.16.0 | Changes the HTML tags kept in an event description sent to Google Calendar. |
sugar_calendar_google_meet_space_config | Filter | 3.16.0 | Changes the Google Meet meeting settings, such as who can join without asking. Passes $config and $event. |
sugar_calendar_google_pull_chunk_size | Filter | 3.16.0 | Sets how many Google events each background sync run fetches. Defaults to 250. |
sugar_calendar_google_webhook_event_{$event_type} | Action | 3.16.0 | Fires after Sugar Calendar Events handles a Google Calendar webhook event. Passes the webhook payload. |
sugar_calendar_integrations_elementor_loop_grid_query_args | Filter | 3.10.0 | Changes the event query for the Elementor Loop Grid widget. |
sugar_calendar_ai_assistant_enabled | Filter | 3.15.0 | Return false to turn off the Gia AI assistant site-wide. To learn more, see our guide to using Gia AI. |
sugar_calendar_abilities_register | Filter | 3.13.0 | Adds or changes the abilities Sugar Calendar Events offers to AI assistants. To learn more, see our guide to using Sugar Calendar Events with AI assistants. |
Legacy Hooks
These hooks belong to Sugar Calendar’s older calendar and event list shortcodes and widgets. They still work, but they don’t run for the Calendar and Event List blocks. For new projects, use the hooks in the sections above.
| Hook | Type | What it does |
|---|---|---|
sc_before_calendar | Action | Fires before the legacy calendar output. |
sc_after_calendar | Action | Fires after the legacy calendar output. |
sc_before_events_list | Action | Fires before the legacy events list. |
sc_after_events_list | Action | Fires after the legacy events list. |
sc_before_event_list_item | Action | Fires before each item in the legacy events list. Passes the event ID. |
sc_after_event_list_item | Action | Fires after each item in the legacy events list. Passes the event ID. |
sc_before_calendar_widget | Action | Fires before the calendar widget. |
sc_after_calendar_widget | Action | Fires after the calendar widget. |
sc_before_event_list_widget | Action | Fires before the event list widget. |
sc_after_event_list_widget | Action | Fires after the event list widget. |
sc_before_category_widget | Action | Fires before the event categories widget. |
sc_after_category_widget | Action | Fires after the event categories widget. |
sc_before_filter_widget | Action | Fires before the event filter widget. |
sc_after_filter_widget | Action | Fires after the event filter widget. |
sc_event_calendar_link | Filter | Changes an event’s link inside the legacy calendar. |
sugar_calendar_legacy_event_list_link | Filter | Changes an event’s link in the legacy events list. Passes the link and $event. |
Examples
Here are a few common customizations to get you started.
Add a Row to the Event Details
This snippet adds a Dress code row after the location on single event pages. Priority 42 places it between the location (40) and link (45) rows.
add_action( 'sugar_calendar_frontend_event_details', function ( $event ) {
echo '<div class="sc-frontend-single-event__details-row">';
echo '<div class="sc-frontend-single-event__details__label">Dress code:</div>';
echo '<div class="sc-frontend-single-event__details__val">Smart casual</div>';
echo '</div>';
}, 42 );
Change the Email From Name
This snippet changes the From name on emails Sugar Calendar Events sends.
add_filter( 'sc_email_from_name', function ( $name ) {
return 'Sullie\'s Flowers Events';
} );
Run Code When a Ticket Order Completes
This snippet runs after Sugar Calendar Events saves a ticket order, for example, to send the order to another system.
add_action( 'sc_et_checkout_complete', function ( $payload, $order_id ) {
error_log( 'Sugar Calendar order completed: ' . $order_id );
}, 10, 2 );
That’s it! You now know how to use the hooks in Sugar Calendar Events to customize your events.
Next, would you like to change how your event archive and single event pages look? Be sure to check out our tutorial on customizing template files to learn how.
