Description
The “gform_twilio_message” filter in the Gravity Forms Twilio Add-On is used to modify the SMS message arguments before it is sent. Only the to, from, and body parameters can be filtered. Adding new parameters is not supported.
Usage
The following would apply to all forms:
add_filter( 'gform_twilio_message', 'your_function_name', 10, 4 );
To target a specific form, append the form id to the hook name. (format: gform_twilio_message_FORMID)
add_filter( 'gform_twilio_message_1', 'your_function_name', 10, 4 );
To target a specific form’s feed, append the form id and feed id to the hook name. (format: gform_twilio_message_FORMID_FEEDID)
add_filter( 'gform_twilio_message_1_1', 'your_function_name', 10, 4 );
Parameters
| Parameter | Type | Description |
|---|---|---|
| $args | array | The arguments for the SMS message. $args = [ 'to' => '7571234567', 'from' => '7571112222', 'body' => 'This is a test.', 'shorten_url' => 1, ]; |
| $feed | Feed Object | The feed object. |
| $entry | Entry Object | The entry object. |
| $form | Form Object | The form object. |
Examples
add_filter( 'gform_twilio_message', 'change_message', 10, 4 );
function change_message( $args, $feed, $entry, $form ) {
$args['body'] = $args['body'] . ' - TEST!';
return $args;
}
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?
Since
This filter was added in Twilio version 2.4.
Source Code
This filter is located in GFTwilio::process_feed() in gravityformstwilio/class-gf-twilio.php.