Campaigns
Campaigns are one-time email blasts sent to a list or segment.
Campaign Statuses
| Status | Meaning |
draft | Not yet sent or scheduled |
scheduled | Will send at scheduled_at |
sending | Active batch send in progress |
sent | Completed |
paused | Paused mid-send (manual or rate-limit) |
Send Modes
| Mode | Behaviour |
immediate | Batches sent immediately on save-and-send |
scheduled | Sends at the specified scheduled_at datetime |
smart | Sends to each subscriber at their optimal hour (requires open history) |
PHP API
php// Create a campaign
$id = OM_Campaign::create([
'subject' => 'Your July Newsletter',
'preview_text' => 'Inside: summer updates and new features',
'from_name' => 'Jane at Acme',
'from_email' => 'jane@acme.com',
'html_content' => '<h1>Hello {{first_name}}</h1>...',
'list_id' => 3, // null = all subscribers
'send_mode' => 'immediate',
]);
// Schedule a campaign
OM_Campaign::schedule( $id, '2026-08-01 09:00:00' );
// Pause a running campaign
OM_Campaign::pause( $id );
// Resume a paused campaign
OM_Campaign::resume( $id );
// Get stats for a campaign
$stats = OM_Campaign::get_stats( $id );
// Returns: open_rate, click_rate, bounce_rate, unsubscribe_rate, total_sent
Hooks
phpadd_action( 'om_campaign_before_send', function( int $campaign_id, array $subscriber_ids ) {} );
add_action( 'om_campaign_sent', function( int $campaign_id ) {} );
add_action( 'om_campaign_paused', function( int $campaign_id ) {} );
// Filter HTML just before each individual email is sent
add_filter( 'om_personalise_html', function( string $html, int $subscriber_id, int $campaign_id ): string {
return $html;
}, 10, 3 );