Mautic hooks
The Mautic client updates contacts in a connected Mautic instance. Updates are not sent while a visitor waits. They go into the action queue and are sent in the background, with retries. This page lists the client’s one settings filter and the queued action types it handles.
cs_mautic_settings
Section titled “cs_mautic_settings”Filter · includes/clients/class-mautic.php
Provides the fields of the Mautic settings page (cs-mautic). Core registers no fields itself, so the page stays empty until an add-on adds fields here. See Settings and admin hooks for the field options.
| Parameter | Type | Description |
|---|---|---|
$fields |
array |
The fields of the page, keyed by field key. Default: an empty array. |
Returns: array — the fields.
add_filter('cs_mautic_settings', function ($fields) { $fields['MY_CONTACT_FIELD'] = [ 'title' => __('Contact field alias', 'my-addon'), 'type' => 'text', 'description' => __('The Mautic contact field that stores the campaign code.', 'my-addon'), ];
return $fields;});Queued contact actions
Section titled “Queued contact actions”The Mautic client handles three action types through the cs_action_{type} filter, described on the action queue page. They are listed here so you know which types are taken. Each callback is called with ($result, $context) and returns the result of the update, or a WP_Error so the action is retried.
| Action type | Filter | Context |
|---|---|---|
mtc_update_contact_field |
cs_action_mtc_update_contact_field |
email, field (the contact field alias), value and action (add, remove or empty to set the value). |
mtc_update_contact_field_bulk |
cs_action_mtc_update_contact_field_bulk |
items: a list of updates, each with email, field, value and optionally action. |
mtc_update_contact_integration |
cs_action_mtc_update_contact_integration |
email, entity (the integration entity name) and entityId. |
To react to an update, or to change what happens with it, add your own callback at a different priority:
add_filter('cs_action_mtc_update_contact_field', function ($result, $context) { if (!is_wp_error($result)) { error_log(sprintf('Mautic field %s updated.', $context['field'])); }
return $result;}, 20, 2);