wp_sms_number_unsubscribed_through_url
Action hook triggered when a subscriber unsubscribes via URL, useful for custom redirects.
The wp_sms_number_unsubscribed_through_url action fires when a user unsubscribes from SMS notifications via a URL link. Use this hook to redirect users to a custom page after unsubscription.
Syntax
add_action('wp_sms_number_unsubscribed_through_url', 'your_callback', 10, 1);
Parameters
| Parameter | Type | Description |
|---|---|---|
$number | string | The phone number of the unsubscribed user |
Example
Redirect users to a custom page after unsubscribing:
add_action('wp_sms_number_unsubscribed_through_url', function($number) {
wp_redirect('/goodbye');
exit;
});
Redirect to Custom Thank You Page
add_action('wp_sms_number_unsubscribed_through_url', function($number) {
wp_redirect(home_url('/unsubscribe-confirmation'));
exit;
});
Log Unsubscription and Redirect
add_action('wp_sms_number_unsubscribed_through_url', function($number) {
// Log the unsubscription
error_log("User unsubscribed: {$number}");
// Redirect to confirmation page
wp_redirect(home_url('/unsubscribed'));
exit;
});
Use Cases
- Redirect to a custom goodbye/thank you page
- Log unsubscription events
- Trigger follow-up actions (e.g., send confirmation email)
- Track unsubscription analytics
Related
- wp_sms_add_subscriber - Action hook for new subscribers
- Newsletter Unsubscribe Endpoint - API endpoint for unsubscription
Last updated: December 23, 2024