MailerPress hooks and filters reference

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

ActionArgumentsFires when
mailerpress_contact_createdint $contact_idA new contact is added (admin, forms, REST API, integrations, automations, incoming webhooks).
mailerpress_contact_updatedint $contact_idA contact is updated.
mailerpress_contact_deletedint $contact_id, string $email, string $first_name, string $last_nameA contact is deleted. The contact no longer exists in the database, so use the passed values.
mailerpress_contact_tag_added
mailerpress_contact_tag_removed
int $contact_id, int $tag_idA tag is added to or removed from a contact.
mailerpress_contact_list_added
mailerpress_contact_list_removed
int $contact_id, int $list_idA contact is added to or removed from a list.
mailerpress_contact_custom_field_added
mailerpress_contact_custom_field_updated
int $contact_id, string $field_key, mixed $valueA custom field value is set for the first time or changed.
mailerpress_subscription_confirmedint $contact_idA contact confirms their subscription (double opt-in link or re-engagement confirmation).
mailerpress_contact_unsubscribedint $contact_idA contact unsubscribes (unsubscribe link, one-click unsubscribe from the mail client, manage subscription page).
mailerpress_user_subscribed_to_list
mailerpress_user_unsubscribed_from_list
int $contact_id, int $list_idA visitor checks or unchecks a list in the [mailerpress_my_lists] form.
mailerpress_list_createdint $list_idA list is created.
mailerpress_tag_createdobject $tag (tag_id, name)A tag is created.
mailerpress_contacts_marked_inactiveint[] $contact_ids, array $details (threshold_date, inactive_after_days)The inactive contacts check moves contacts to inactive.
mailerpress_inactive_contacts_reactivatedint $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.

PHP
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.

PHP
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

HookArgumentsDescription
mailerpress_campaign_created (action)int $campaign_idA 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_idWhether the online version of a campaign is hidden from search engines. See Making MailerPress Email Campaign Previews Indexable.

Tracking and bounces

ActionArgumentsFires when
mailerpress_email_openedint $contact_id, int $campaign_id, int $batch_idAn open is recorded for a known contact. It does not fire with anonymous tracking.
mailerpress_email_clickedint $contact_id, int $campaign_id, string $urlA tracked link is clicked by a known contact. It does not fire with anonymous tracking.
mailerpress_email_bouncedint $contact_id, string $emailThe 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.

HookArgumentsDescription
mailerpress_bounce_require_recent_send (filter)bool $enabled (default true), string $espWhether 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 $daysResult 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_contactsMaximum 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 $espWhether a valid signature is mandatory for this provider.
mailerpress_bounce_webhook_active_esps (filter)string[] $active, string $espProviders allowed to post bounce notifications (by default, your active sending services).
mailerpress_bounce_rejected (action)string $email, string $esp, string $cause, array $metadataAn unsigned bounce is rejected because no matching send was found.
mailerpress_bounce_quarantined (action)string $email, string $esp, string $reason, array $metadataAn unsigned bounce is quarantined because the hourly quota is reached.

Email editor and content

HookArgumentsDescription
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 $requestWP_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 $requestPost 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 $parsedWP_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 $argsQuery used to load the saved patterns.
mailerpress_patterns (filter)WP_Post[] $patternsPatterns returned to the editor.
mailerpress_merge_tag_error (action)string $tag, Throwable $exceptionA 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.

PHP
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.

PHP
// 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:

PHP
add_filter( 'mailerpress/workflows/allowed_custom_hooks', function ( $hooks ) {
	$hooks[] = 'my_plugin_order_validated';
	return $hooks;
} );

Automation filters and actions

HookArgumentsDescription
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 $contextA trigger starts an automation run.
mailerpress_workflow_trigger_rate_limited (action)string $trigger_key, int $user_idA run is not started because of the rate limit.
mailerpress_workflow_job_started (action)AutomationJob $job, array $contextAn automation run starts executing.
mailerpress_workflow_step_executed (action)AutomationJob $job, Step $step, StepResult $result, array $contextA step is completed.
mailerpress_workflow_job_completed (action)AutomationJob $jobAn automation run is completed.
mailerpress_workflow_job_failed (action)AutomationJob $job, string $errorAn automation run fails.
mailerpress_workflow_status_changed (action)int $automation_id, string $statusAn 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)

ActionArgumentsFires when
mailerpress_webhook_receivedstring $webhook_id, array $payload, WP_REST_Request $requestAn enabled incoming webhook receives a valid request.
mailerpress_webhook_contact_upsertedstring $webhook_id, array $result, array $payload, WP_REST_Request $requestAn incoming webhook creates or updates a contact.
mailerpress_outgoing_webhook_processedstring $event_key, array $data, array $responses, int $attemptAn 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)

FilterArgumentsDescription
gform_mailerpress_override_empty_fieldsbool $override (default true), array $form, array $entry, array $feedGravity 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_thresholdfloat $score (default 0.5)Bricks Builder: minimum reCAPTCHA v3 score required to accept a MailerPress form submission.

Contact imports

FilterDefaultDescription
mailerpress_import_chunk_size500Number of contacts per import chunk. MailerPress keeps the value between 50 and 2,000.
mailerpress_import_parallel_chunks20Number 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

FilterArgumentsDescription
mailerpress_trusted_proxiesstring[] $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_enabledbool $enabled, string $role, string $capability, string $base_capabilityWhether a role receives a MailerPress capability when MailerPress assigns its capabilities (on activation and after each MailerPress update). See MailerPress capabilities.
mailerpress_exportable_settings_maparray $mapSettings available in MailerPress > Tools > Export / Import. See Export and Import Settings.
mailerpress_white_label_optionsarray $optionsWhite label settings. The White Label screen generates a ready-to-use snippet; see Enable the White Label feature.
mailerpress_remote_promotions_enabledbool $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.

PHP
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.