Filter: wp_sms_single_dispatch_arguments

Updated on May 26, 2024

The wp_sms_single_dispatch_arguments filter allows developers to modify the arguments used before dispatching an SMS to a single number. This can be useful for customizing the SMS parameters, such as the recipient’s number, message content, or any other related argument.

Parameters

  • $arguments (array): The arguments for sending an SMS.
  • to (string): The recipient’s phone number.
  • msg (string): The SMS message content.

Example Usage

This example demonstrates how to append an unsubscribe link to each SMS message before it is sent.

add_filter('wp_sms_single_dispatch_arguments', function ($arguments) {
    // Generate the unsubscribe link based on the recipient's phone number
    $unsubscribeLink = \WP_SMS\Newsletter::generateUnSubscribeUrlByNumber($arguments['to']);

    // Append the unsubscribe link to the message content
    $arguments['msg'] .= "\r" . $unsubscribeLink;

    // Return the modified arguments
    return $arguments;
});

Notes

  • Ensure that the \WP_SMS\Newsletter::generateUnSubscribeUrlByNumber method exists and is correctly implemented to generate the unsubscribe URL.
  • Use this filter to customize or enhance the SMS dispatch process as per your requirements.