Description
The gravitysmtp_twilio_alert_request_body
filter can be used to modify the request body that is sent to the Twilio API when sending SMS alerts through Gravity SMTP.
Usage
add_filter( 'gravitysmtp_twilio_alert_request_body', 'your_function_name', 10, 2 );
Parameters
Parameter | Type | Description |
---|---|---|
$request_body | array | The request body array that will be sent to Twilio. Default contains ‘ApplicationSid’, ‘Body’, ‘To’, and ‘From’ fields. |
$send_args | array | The original send arguments containing ‘account_id’, ‘auth_token’, ‘to’, ‘from’, and ‘message’ keys. |
Examples
Add custom Twilio message parameters.
add_filter( 'gravitysmtp_twilio_alert_request_body', 'customize_twilio_message', 10, 2 );
function customize_twilio_message( $request_body, $send_args ) {
// Add Twilio-specific parameters
$request_body['StatusCallback'] = 'https://yoursite.com/twilio-webhook';
$request_body['ValidityPeriod'] = 1440; // 24 hours in minutes
return $request_body;
}
Placement
This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.
See also the PHP section in this article: Where Do I Put This Code?
Source Code
This filter is located in class-twilio-alert-connector.php.