MailerPress fires WordPress actions and filters (hooks) that let developers react to contact, campaign and tracking events, adjust queries and limits, and connect MailerPress to their own code. This page lists the main public hooks of MailerPress and MailerPress Pro, by topic, with their arguments. Hooks not listed here are internal and may change without notice.
Most hooks below are part of MailerPress (free). Hooks in sections marked โ(MailerPress Pro)โ only fire when MailerPress Pro is active.
Where to add your code
Add your snippets to a custom plugin, a must-use plugin (wp-content/mu-plugins) or the functions.php file of a child theme. Many MailerPress events run in the background through Action Scheduler, so load your code on every request, not only in the admin. When a hook passes several arguments, set the number of accepted arguments in add_action() or add_filter().
Contacts and subscriptions
| Action | Arguments | Fires when |
|---|---|---|
mailerpress_contact_created | int $contact_id | A new contact is added (admin, forms, REST API, integrations, automations, incoming webhooks). |
mailerpress_contact_updated | int $contact_id | A contact is updated. |
mailerpress_contact_deleted | int $contact_id, string $email, string $first_name, string $last_name | A contact is deleted. The contact no longer exists in the database, so use the passed values. |
mailerpress_contact_tag_addedmailerpress_contact_tag_removed | int $contact_id, int $tag_id | A tag is added to or removed from a contact. |
mailerpress_contact_list_addedmailerpress_contact_list_removed | int $contact_id, int $list_id | A contact is added to or removed from a list. |
mailerpress_contact_custom_field_addedmailerpress_contact_custom_field_updated | int $contact_id, string $field_key, mixed $value | A custom field value is set for the first time or changed. |
mailerpress_subscription_confirmed | int $contact_id | A contact confirms their subscription (double opt-in link or re-engagement confirmation). |
mailerpress_contact_unsubscribed | int $contact_id | A contact unsubscribes (unsubscribe link, one-click unsubscribe from the mail client, manage subscription page). |
mailerpress_user_subscribed_to_listmailerpress_user_unsubscribed_from_list | int $contact_id, int $list_id | A visitor checks or unchecks a list in the [mailerpress_my_lists] form. |
mailerpress_list_created | int $list_id | A list is created. |
mailerpress_tag_created | object $tag (tag_id, name) | A tag is created. |
mailerpress_contacts_marked_inactive | int[] $contact_ids, array $details (threshold_date, inactive_after_days) | The inactive contacts check moves contacts to inactive. |
mailerpress_inactive_contacts_reactivated | int $count, array $details (threshold_date, reactivated_at) | Inactive contacts are reactivated after a new click. |
Example: run your own code when a contact receives a specific tag.
add_action( 'mailerpress_contact_tag_added', function ( $contact_id, $tag_id ) {
if ( 12 !== (int) $tag_id ) {
return;
}
// Notify your CRM, log the event, etc.
error_log( sprintf( 'MailerPress contact %d received tag %d', $contact_id, $tag_id ) );
}, 10, 2 );Add a contact from your own code
add_mailerpress_contact() creates a contact, or updates it if the email address already exists. Pass at least email; you can add first_name, last_name, lists and tags (IDs) and opt_in_source. Without lists, the contact goes to your default list. Without subscription_status, MailerPress applies your sign-up confirmation setting: with double opt-in enabled, the contact is pending and receives the confirmation email. The function returns an array with success and contact_id, or success and error.
function my_plugin_subscribe( $email, $first_name ) {
if ( ! function_exists( 'add_mailerpress_contact' ) ) {
return;
}
$result = add_mailerpress_contact( [
'email' => $email,
'first_name' => $first_name,
'lists' => [ 2 ],
'tags' => [ 5 ],
'opt_in_source' => 'my_plugin',
] );
if ( empty( $result['success'] ) ) {
error_log( 'MailerPress: ' . $result['error'] );
}
}Campaigns
| Hook | Arguments | Description |
|---|---|---|
mailerpress_campaign_created (action) | int $campaign_id | A campaign is created. |
mailerpress_campaign_scheduled (action) | int $campaign_id, array $data (batch_id, scheduled_time as a Unix timestamp, total_emails) | A campaign is scheduled for later. |
mailerpress_campaign_sent (action) | int $campaign_id, array $data (campaign_name, campaign_subject, total_emails, sent_emails, error_emails, sent_at) | A campaign batch reaches the sent status. |
mailerpress_max_revisions (filter) | int $max (default 5) | Number of revisions kept per campaign. See Increase the number of revisions per email campaign. |
mailerpress_campaign_preview_noindex (filter) | bool $noindex (default true), int $campaign_id | Whether the online version of a campaign is hidden from search engines. See Making MailerPress Email Campaign Previews Indexable. |
Tracking and bounces
| Action | Arguments | Fires when |
|---|---|---|
mailerpress_email_opened | int $contact_id, int $campaign_id, int $batch_id | An open is recorded for a known contact. It does not fire with anonymous tracking. |
mailerpress_email_clicked | int $contact_id, int $campaign_id, string $url | A tracked link is clicked by a known contact. It does not fire with anonymous tracking. |
mailerpress_email_bounced | int $contact_id, string $email | The IMAP bounce mailbox check marks a contact as bounced. |
Bounce webhooks from email service providers (MailerPress Pro)
MailerPress Pro receives bounce notifications (undeliverable emails) from your email service provider. An unsigned notification is applied only if the site recently sent an email to that address through the same provider, and only up to an hourly limit. These filters adjust that protection.
| Hook | Arguments | Description |
|---|---|---|
mailerpress_bounce_require_recent_send (filter) | bool $enabled (default true), string $esp | Whether an unsigned bounce must match a recent send. |
mailerpress_bounce_correlation_window_days (filter) | int $days (default 30) | How far back MailerPress looks for a matching send. |
mailerpress_bounce_has_recent_send (filter) | bool $found, string $email, string $esp, int $days | Result of the send lookup, for example to also accept emails sent by another system through the same provider. |
mailerpress_bounce_quota_per_hour (filter) | int $quota, int $total_contacts | Maximum number of unsigned bounces applied per hour. Default: 50 or 2% of your contacts, whichever is higher. Beyond it, bounces are quarantined and contacts are left unchanged. |
mailerpress_bounce_webhook_rate_limit (filter) | array $limit (default limit 300, window 60) | Maximum requests per IP address and per window (in seconds) on the bounce endpoints. |
mailerpress_bounce_webhook_signature_required (filter) | bool $required, string $esp | Whether a valid signature is mandatory for this provider. |
mailerpress_bounce_webhook_active_esps (filter) | string[] $active, string $esp | Providers allowed to post bounce notifications (by default, your active sending services). |
mailerpress_bounce_rejected (action) | string $email, string $esp, string $cause, array $metadata | An unsigned bounce is rejected because no matching send was found. |
mailerpress_bounce_quarantined (action) | string $email, string $esp, string $reason, array $metadata | An unsigned bounce is quarantined because the hourly quota is reached. |
Email editor and content
| Hook | Arguments | Description |
|---|---|---|
mailerpress_editor_auto_save (filter) | int $seconds (default 60) | Autosave delay of the email editor. See Adjust autosave delay in the email editor. |
mailerpress_post_types_public (filter) | WP_Post_Type[] $post_types (keyed by slug) | Post types offered when you insert WordPress content into an email. |
mailerpress_posts_query_args (filter) | array $args, WP_REST_Request $request | WP_Query arguments used to list posts in the editor. |
mailerpress_rest_prepare_{post_type} (filter) | WP_REST_Response $response, WP_Post $post, WP_REST_Request $request | Post data returned to the editor for a given post type, for example mailerpress_rest_prepare_product. |
mailerpress_dynamic_post_query_args (filter) | array $query, array $parsed | WP_Query arguments used when dynamic post blocks are rendered at send time, for example in automatic latest posts emails. |
mailerpress_patterns_query_args (filter) | array $args | Query used to load the saved patterns. |
mailerpress_patterns (filter) | WP_Post[] $patterns | Patterns returned to the editor. |
mailerpress_merge_tag_error (action) | string $tag, Throwable $exception | A custom merge tag callback throws an error. The tag is replaced by an empty value and sending continues. |
To add your own personalization tags, use mailerpress_register_merge_tag_group(), described in Create custom merge tags for the MailerPress email editor.
Example: remove pages from the content you can insert into emails.
add_filter( 'mailerpress_post_types_public', function ( $post_types ) {
unset( $post_types['page'] );
return $post_types;
} );Subscription pages
mailerpress_pages_rendered_content (filter) receives the HTML generated by the [mailerpress_pages] shortcode and an array with action (confirm, confirm_unsubscribe, manage, reengagement_confirm or unsubscribe), atts (shortcode attributes) and is_preview. Return the HTML to display. To design these pages without code, see Design the Manage Subscription and Unsubscribed Pages in MailerPress.
Automations
Start an automation from your own code
The Custom Hook trigger starts an automation when a WordPress action fires. By default, it accepts hook names that start with mailerpress_custom_. In the trigger settings, enter the Hook Name and choose the type of each parameter (Email Address, User ID, Contact ID or Custom Data); the Code Example field shows the matching do_action() call. With an email address, MailerPress creates a pending contact if the address is unknown. The automation must be created by an administrator and enabled.
// Parameter 1 Type: Email Address
do_action( 'mailerpress_custom_course_completed', $user_email );To use an existing hook name that does not start with mailerpress_custom_, allow it with the mailerpress/workflows/allowed_custom_hooks filter:
add_filter( 'mailerpress/workflows/allowed_custom_hooks', function ( $hooks ) {
$hooks[] = 'my_plugin_order_validated';
return $hooks;
} );Automation filters and actions
| Hook | Arguments | Description |
|---|---|---|
mailerpress_trigger_rate_limit_max (filter) | int $max (default 5) | Maximum number of automation runs a trigger can start for the same person within the window. |
mailerpress_trigger_rate_limit_window (filter) | int $seconds (default 60) | Length of that window. |
mailerpress_cleanup_job_retention_days (filter) | int $days (default 30) | Completed, failed and cancelled automation runs older than this are deleted by the daily cleanup. |
mailerpress_cleanup_log_retention_days (filter) | int $days (default 90) | Automation logs older than this are deleted by the daily cleanup. |
mailerpress_workflow_trigger_fired (action) | string $trigger_key, AutomationJob $job, array $context | A trigger starts an automation run. |
mailerpress_workflow_trigger_rate_limited (action) | string $trigger_key, int $user_id | A run is not started because of the rate limit. |
mailerpress_workflow_job_started (action) | AutomationJob $job, array $context | An automation run starts executing. |
mailerpress_workflow_step_executed (action) | AutomationJob $job, Step $step, StepResult $result, array $context | A step is completed. |
mailerpress_workflow_job_completed (action) | AutomationJob $job | An automation run is completed. |
mailerpress_workflow_job_failed (action) | AutomationJob $job, string $error | An automation run fails. |
mailerpress_workflow_status_changed (action) | int $automation_id, string $status | An automation is enabled or disabled. |
The automation classes are in the MailerPress\Core\Workflows\Models (AutomationJob, Step) and MailerPress\Core\Workflows\Results (StepResult) namespaces. For example, $job->getAutomationId() returns the automation ID.
Webhooks (MailerPress Pro)
| Action | Arguments | Fires when |
|---|---|---|
mailerpress_webhook_received | string $webhook_id, array $payload, WP_REST_Request $request | An enabled incoming webhook receives a valid request. |
mailerpress_webhook_contact_upserted | string $webhook_id, array $result, array $payload, WP_REST_Request $request | An incoming webhook creates or updates a contact. |
mailerpress_outgoing_webhook_processed | string $event_key, array $data, array $responses, int $attempt | An outgoing webhook delivery attempt is finished. $responses is keyed by URL. |
See the MailerPress Webhooks Guide for the list of events and the payload format.
Form integrations (MailerPress Pro)
| Filter | Arguments | Description |
|---|---|---|
gform_mailerpress_override_empty_fields | bool $override (default true), array $form, array $entry, array $feed | Gravity Forms: whether empty form fields overwrite existing contact values. Add _{form_id} to target one form, for example gform_mailerpress_override_empty_fields_3. |
mailerpress/bricks/recaptcha_score_threshold | float $score (default 0.5) | Bricks Builder: minimum reCAPTCHA v3 score required to accept a MailerPress form submission. |
Contact imports
| Filter | Default | Description |
|---|---|---|
mailerpress_import_chunk_size | 500 | Number of contacts per import chunk. MailerPress keeps the value between 50 and 2,000. |
mailerpress_import_parallel_chunks | 20 | Number of import chunks scheduled in parallel. MailerPress keeps the value between 5 and 100. |
Lower these values on a small shared hosting plan if imports time out.
Security, settings and administration
| Filter | Arguments | Description |
|---|---|---|
mailerpress_trusted_proxies | string[] $proxies (default empty) | Exact IP addresses of your reverse proxies or load balancers. For requests from these addresses only, MailerPress reads the visitor IP from forwarded headers such as X-Forwarded-For, X-Real-IP or CF-Connecting-IP. This IP is used by the form spam protection rate limit and the API key IP restrictions. |
mailerpress_role_capability_enabled | bool $enabled, string $role, string $capability, string $base_capability | Whether a role receives a MailerPress capability when MailerPress assigns its capabilities (on activation and after each MailerPress update). See MailerPress capabilities. |
mailerpress_exportable_settings_map | array $map | Settings available in MailerPress > Tools > Export / Import. See Export and Import Settings. |
mailerpress_white_label_options | array $options | White label settings. The White Label screen generates a ready-to-use snippet; see Enable the White Label feature. |
mailerpress_remote_promotions_enabled | bool $enabled (default true) | Whether MailerPress fetches promotions from mailerpress.com to display in its admin. |
Example: your site is behind a proxy at 203.0.113.10, and you don’t want MailerPress to load promotions.
add_filter( 'mailerpress_trusted_proxies', function ( $proxies ) {
$proxies[] = '203.0.113.10';
return $proxies;
} );
add_filter( 'mailerpress_remote_promotions_enabled', '__return_false' );To manage contacts and campaigns from another application, use the MailerPress public REST API. For command-line tools, see MailerPress WP-CLI commands.