Hooks

Hooks: Display Rules and Content Source

5 min read

These hooks control where notifications may appear (display rules) and what data populates dynamic tags (content source pools, filters, and smart targeting).

Index: Hook Reference Hub. Eligibility pipeline: Notifications and Eligibility.

Pro extends advanced rule types via Pro Integration Bridge (display rule and content source filters).

Display rules (filters)

HookParametersDescription
notifal/onpage/display_rules/sanitized_settingsarray $sanitized, array $raw_settingsSanitized display rules before save
notifal/onpage/display_rules/supported_typesarray $rule_typesSupported rule type definitions (Pro adds categories, URL, users)
notifal/onpage/display_rules/before_validationarray $rules, string $combination_logic, array $contextRules before server-side validation
notifal/onpage/display_rules/evaluation_result`boolnull $result, array $rules, string $combination_logic, array $context`Override rule evaluation (null = use core logic)

Client-side display rules (filters)

Rules evaluated in JavaScript after the eligibility response.

HookParametersDescription
notifal/onpage/client_user_rules`arraynull $clientRules, int $notificationId`Visit history rules (new/return/first session)
notifal/onpage/client_cart_rules`arraynull $clientRules, int $notificationId`WooCommerce cart rules for JS evaluation
notifal/onpage/client_page_rules`arraynull $clientRules, int $notificationId`Page targeting rules for JS evaluation
notifal/onpage/user_display_rules/matchbool $matches, array $rule_data, array $auth_contextServer-side login/role rule match result

WooCommerce cart context (filters)

HookParametersDescription
notifal/onpage/woocommerce/cart_contextarray $cart, array $contextNormalized cart snapshot for rule evaluation
notifal/onpage/content_source/cart_product_pool_idsint[] $productIds, array $condition, array $cartProduct IDs derived from cart for pool building

Smart targeting (filters)

HookParametersDescription
notifal/onpage/smart_targeting_excluded_singular_post_typesstring[] $postTypesSingular post types excluded from smart targeting (default includes page)
notifal/onpage/smart_targeting_ui_visiblebool $isVisible, array $notificationDataWhether Smart Targeting UI shows in editor (Pro may hide for page-only templates)

Pro implements smart targeting pool resolution via notifal/onpage/content_source/resolve_pool and related filters.

Content source settings (filters)

HookParametersDescription
notifal/onpage/content_source_settingsarray $settingsParsed content source settings
notifal/onpage/content_source/sanitized_settingsarray $sanitized, array $raw_settingsSanitized settings before save/use
notifal/onpage/order_filtersarray $filtersOrder filters before content source queries
notifal/onpage/product_filtersarray $filtersProduct filters before content source queries
notifal/onpage/user_filtersarray $filtersUser filters before content source queries

Entity pools and resolution (filters)

HookParametersDescription
notifal/onpage/content_source/entity_filtersarray $filters, string $entity_type, array $settings, array $page_contextPer-entity filters before pool query
notifal/onpage/content_source/pool_cache_keystring $cache_key, string $entity_type, array $settings, array $page_contextExtend pool cache key (e.g. smart targeting)
notifal/onpage/content_source/resolve_pool`arraynull $pool, array $context`Return pool array to bypass default loader, or null to defer

$entity_type examples: product, order, post, page, comment, custom_posttype:{slug}.

Product pool caching (filters)

HookParametersDescription
notifal/onpage/product_pool/sizeint $pool_size, array $content_source_settingsNumber of products fetched (default 18)
notifal/onpage/product_pool/timeoutint $timeout, array $content_source_settingsCache TTL in seconds (default 720)
notifal/onpage/product_pool/sale_revalidation_intervalint $interval, array $content_source_settingsSale re-check interval for cached pools (min 60)

Order pool caching (filters)

HookParametersDescription
notifal/onpage/order_pool/sizeint $pool_size, array $content_source_settingsNumber of orders fetched (default 18)
notifal/onpage/order_pool/timeoutint $timeout, array $content_source_settingsCache TTL in seconds (default 720)

Retrigger variants (filter)

HookParametersDescription
notifal/onpage/retrigger_variants/maxint $maxMax pre-rendered pool variants for client-side retrigger

Cache cleared (actions)

Pool cache invalidation actions are listed under notification CRUD in Notifications and Eligibility:

  • notifal/onpage_notification/order_pool_cache_cleared
  • notifal/onpage_notification/product_pool_cache_cleared

Pro comment content source bridge (filters)

Registered by Notifal Pro when licensed. Base plugin calls these with empty defaults when Pro is inactive.

HookParametersDescription
notifal_pro_build_comment_filtersarray $filters, array $settingsComment filter definitions for content source
notifal_pro_fetch_comment_poolarray $pool, array $filters, array $settingsComment pool items
notifal_pro_get_comment_count`intnull $count, array $settings, array $filters`Comment count for counter tags
notifal_pro_build_comment_based_contextarray $settings, array $pageContextTag context for comment-based source
notifal_pro_add_comment_context_to_post_basedarray $context, ...Add comment data to post-based context
notifal_pro_add_comment_context_to_page_basedarray $context, ...Add comment data to page-based context
notifal_pro_add_comment_context_to_mixedarray $context, ...Add comment data to mixed source context
notifal_pro_add_comment_context_to_{entityType}dynamicEntity-specific comment context (dynamic suffix)
notifal_pro_get_hidden_comment_restrictionsarray $detectedCategoriesHidden comment restrictions in tag category detector

Full Pro license documentation: Pro Integration Bridge.

Hooks series

  1. Hook Reference Hub
  2. Hooks: Lifecycle and Bootstrap
  3. Hooks: Notifications and Eligibility
  4. Hooks: Templates and Rendering
  5. Hooks: Tags and Dynamic Data
  6. Hooks: Display Rules and Content Source (you are here)
  7. Hooks: Analytics and Tracking
  8. Hooks: Admin UI Extension
  9. Hooks: Pro Integration Bridge