Skip to content

Ignition Favorites — Developer Reference

The Ignition Favorites add-on stores one row per (user, campaign) favorite and renders its UI through core’s campaign render hooks. It exposes the following surfaces for themes and other plugins.

Hook Parameters Description
igcf_favorites_favorited $user_id, $campaign_id Fires when a user newly favorites a campaign. Only fires on a real state change — re-favoriting an already-favorited campaign is idempotent and does not fire again.
igcf_favorites_unfavorited $user_id, $campaign_id Fires when a user removes an existing favorite. Only fires on a real state change.

The add-on exposes no filters of its own. Its rendering is driven by core hooks — igcf_campaign_card_media, igcf_after_campaign_title, igcf_campaign_progress_stats_end, and igcf_sidebar_after_stats (see the Actions Reference) — and its settings page registers through the core igcf_addon_settings filter.

Base namespace igcf/v1. Both methods act on the current user (any user id in the request body is ignored) and are idempotent.

Method Route Description
PUT /igcf/v1/campaigns/{id}/favorite Favorite the campaign for the current user.
DELETE /igcf/v1/campaigns/{id}/favorite Remove the current user’s favorite.

Both return { "favorited": <bool>, "count": <int> } on success (HTTP 200). The route returns 401 when the request is not authenticated, 404 when the campaign does not exist or is not publicly visible, and 500 on a storage error.

Igcf_Favorites_Service is a static API you can call directly from PHP. It keeps a per-request cache of each user’s favorites and flushes it after writes.

Method Returns Description
add( $user_id, $campaign_id ) bool Add a favorite (idempotent).
remove( $user_id, $campaign_id ) bool Remove a favorite (idempotent).
is_favorited( $user_id, $campaign_id ) bool Whether the user has favorited the campaign.
count_for_campaign( $campaign_id ) int Total favorites for a campaign.
get_user_favorites( $user_id ) int[] Favorited campaign IDs, newest first.
delete_for_user( $user_id ) int|false Remove all of a user’s favorites (used by privacy erase and user deletion).
delete_for_campaign( $campaign_id ) int|false Remove all favorites for a campaign (used on campaign deletion).

The igcf_favorites_favorited and igcf_favorites_unfavorited actions fire from add() and remove() on real state changes, whether the change originates from the REST route or a direct service call.

To respect the site’s public-count visibility setting before rendering a count yourself, call Igcf_Favorites_Settings::should_display_count( $count ) — it returns whether the count should be shown under the configured rule.