Skip to main content

Hooks and filters

SearchSync's hooks are named tangible_searchsync_*. Many also have an older tgbl_alg_* or tgbl_ss_* name; where both exist, the old name runs first and the new one runs on its result, so the new name has the final say. Use the new names in new code.

Indexing​

FilterArgumentsUse it to
tangible_searchsync_alter_record$record, $post, $index_nameAdd, change or remove fields on a record before it's saved
tangible_searchsync_should_index_post$should_index, $post, $index_nameKeep individual posts out of an index
tangible_searchsync_posts_to_index$postsChange the list of posts a reindex processes
tangible_searchsync_posts_to_index_query_args$query_args, $content_types, $argsChange the query a reindex uses to find posts
tangible_searchsync_reindex_on_term_edit$should_reindex, $taxonomyStop term edits reindexing their posts, per taxonomy
tangible_searchsync_default_index_attributes$rowsChange the attributes new indexes start with
tangible_searchsync_index_languages$languages (code → name)Add languages to the Index Language setting
tangible_searchsync_indexed_content_max_bytes$bytesChange the 6,000-byte limit on post content. Return 0 for no limit
tangible_searchsync_indexed_content$text, $raw, $postChange the post content that's indexed
tangible_searchsync_author_avatar_args$args, $user_idChange the indexed author avatar (default 96px). Reindex afterwards
tangible_searchsync_index_settings_payload$payload, $index_settingsChange the settings pushed to the backend

For example, to keep password-protected posts out of every index:

add_filter( 'tangible_searchsync_should_index_post', function ( $should_index, $post ) {
return $should_index && $post->post_password === '';
}, 10, 2 );

Access control​

Access control is off until you switch it on for an index. Return the attribute that holds each record's access claims, such as ld_group_ids for LearnDash groups:

add_filter( 'tangible_searchsync_access_attribute', function ( $attribute, $index ) {
return $index === 'courses_index' ? 'ld_group_ids' : $attribute;
}, 10, 2 );

Records without any claims are marked public when they're indexed, so reindex after turning this on. The Local backend uses tangible_searchsync_local_access_attribute in the same way.

Backends and providers​

FilterUse it to
tangible_searchsync_register_backendChoose the active backend by id. See Custom backends
tangible_searchsync_register_providerRegister a personalisation provider
tangible_searchsync_local_relevance_capChange how many top results the Local backend sorts within (default 1,000)

Display​

HookUse it to
tangible_searchsync_user_state_labelsRename status labels such as "Enrolled" and "In progress"
tangible_searchsync_virtual_datapointsAdd or change the per-visitor card datapoints
tgbl_ss_card_template_contentChange a card template's HTML before it's used
tgbl_ss_before_global_search (action)Output content before the search override results
tgbl_ss_after_global_search (action)Output content after the search override results
tangible_searchsync_log_fileChange where the debug log is written

JavaScript filters​

These use wp.hooks.

FilterArgumentsUse it to
tangible_searchsync_hit_templatetemplate, { hit, html, component, widget }Replace a result card's markup completely
searchsync.filters.preselectChange a filter's preselected values

Browser globals​

NameWhat it is
window.tangibleSearchsyncInstancesThe InstantSearch instances on the page
searchsyncInstanceCreatedA CustomEvent fired on window when an instance is created