This guide explains the available hooks in the WPSubscription and WPSubscription Pro plugins. These hooks allow developers to trigger custom logic at different stages of the subscription lifecycle or modify subscription-related behavior.
What Are Hooks?
Hooks let developers:
Trigger actions when a subscription is created, canceled, expired, etc.
Customize WooCommerce behavior during renewals or cart handling
Integrate with external tools (via REST API or automation tools)
Hooks are available as:
do_action()
(Actions): Trigger a function at a specific pointadd_filter()
(Filters): Modify data before it is returned or saved
Free Version Hooks
These are available in the free WPSubscription plugin.
Action Hooks
Hook Name | Triggered When | Parameters |
---|---|---|
| Subscription is activated |
|
| Subscription expires |
|
| Subscription is cancelled |
|
| Subscription marked for cancellation |
|
| Subscription status is pending |
|
| Resumed from cancellation |
|
| Status changes |
|
| Email alert to admin |
|
Pro Version Hooks
These are available only in WPSubscription Pro and used mostly for automation and integrations.
REST API Hooks
Hook Name | Triggered When | Parameters |
---|---|---|
| Cancelled via API |
|
| Paused via API |
|
| Reactivated via API |
|
| Status changed via API |
|
| Trial ends |
|
| Marked expired |
|
| Payment fails |
|
| API key is verified |
|
Email Notification Hooks
Used to customize the content and behavior of emails sent to customers or admins.
Hook Name | Purpose |
---|---|
| Admin email on status change |
| Customer email for expired subscription |
| System email trigger for expiry |
Example: Customize Email Content
add_action('subscrpt_subscription_expired_email', function($subscription_id) {
add_filter('woocommerce_email_content', function($content) use ($subscription_id) {
return $content . "\n\nRenew today and save 10%!";
});
});
Checkout & Cart Filters
These allow customization of how subscription products behave during renewal and checkout.
Filter Name | Description |
---|---|
| Add meta to renewal order |
| Modify product args for renewals |
| Modify cart item data for subscriptions |
Admin Filters
Filter Name | Description |
---|---|
| Customize admin notices for subscriptions |
| Add plugin action links (e.g., Settings, Upgrade) |
Automation Hooks
Used by third-party plugins for Automations or similar external tools for programmatic subscription control.
Hook | Description |
---|---|
| Cancel subscription via external trigger |
| Pause subscription |
| Resume paused subscription |
| Change status manually |
| Reactivate a cancelled subscription |
Best Practices
Use
add_action()
oradd_filter()
with a unique callback functionUse priority and number of accepted arguments correctly:
add_action('subscrpt_subscription_activated', 'my_custom_function', 10, 1);
Use Cases
Send a custom Slack alert on failed renewals
Automatically assign roles on activation
Trigger CRM workflows on pause or cancellation
Extend email templates with loyalty offers
Update external dashboards on subscription changes