Automation Sequences
OM_Automation provides trigger-based drip sequences. Each automation has one trigger and an ordered list of steps.
Trigger Types
| Trigger | Description |
|---|---|
subscribe | Fires when a subscriber is added |
tag_added | Fires when a specific tag is assigned |
form_submit | Fires when an OForms form is submitted |
wp_hook | Fires on any custom WordPress action |
wc_purchase | WooCommerce: order payment complete |
wc_abandoned_cart | WooCommerce: cart abandoned for 60+ min |
wc_refund | WooCommerce: order refunded |
wc_review_left | WooCommerce: product review posted |
rss_updated | RSS feed has new items |
Step Types
| Step | Config | ||
|---|---|---|---|
send_email | { subject, body } — sends email to subscriber | ||
delay | `{ unit: 'minutes' | 'hours' | 'days', value: int }` |
add_tag | { tag_id: int } | ||
remove_tag | { tag_id: int } | ||
update_field | { field_key: string, value: string } | ||
condition | { type: condition_type, value: any, yes_steps: [], no_steps: [] } |
PHP API
php// Create an automation
$auto_id = OM_Automation::create(
'Welcome Series',
'subscribe', // trigger_type
'' // trigger_value (for tag_added: tag slug; for wp_hook: hook name)
);
// Define the steps
OM_Automation::save_steps( $auto_id, [
[ 'step_type' => 'send_email', 'step_config' => [ 'subject' => 'Welcome!', 'body' => 'Hi {{first_name}}...' ], 'sort_order' => 1 ],
[ 'step_type' => 'delay', 'step_config' => [ 'unit' => 'days', 'value' => 3 ], 'sort_order' => 2 ],
[ 'step_type' => 'add_tag', 'step_config' => [ 'tag_id' => 7 ], 'sort_order' => 3 ],
[ 'step_type' => 'send_email', 'step_config' => [ 'subject' => 'Day 3 follow-up', 'body' => '...' ], 'sort_order' => 4 ],
]);
// Manually trigger an automation for a subscriber
OM_Automation::trigger( 'subscribe', $subscriber_id );
// Enable / disable
OM_Automation::update( $auto_id, [ 'status' => 'active' ] ); // active|paused
Cron
om_process_automations runs every 5 minutes. It queries om_automation_runs for rows where next_run_at <= NOW() and status = 'running', then advances each run to its next step.
