• Resolved Mo

    (@nadhonar)


    Hi there

    Is it possible to use patterns in content message?

    For example, I can insert the -Variable- display name {display_name} of the subscriber (WP user) in content message of SMS.

    Regards

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Amir

    (@amirfallah)

    Hi @nadhonar

    This option is not currently available, but it is planned to be added in the redesign of the SMS sending page in future updates.

    However, for now, You can use the wp_sms_single_dispatch_arguments filter.

    For more information and how to use this filter, please refer to the link below:
    https://wp-sms-pro.com/resources/filter-wp_sms_single_dispatch_arguments/

    Please let me know if you have any further questions or need assistance.
    Regards,

    • This reply was modified 8 months, 1 week ago by Amir.
    Thread Starter Mo

    (@nadhonar)

    Right; Could you please provide me the filter code in order to insert {display_name} into the content message.

    Regards

    Plugin Author Mostafa Soufi

    (@mostafas1990)

    An example should be like this

    add_filter('wp_sms_single_dispatch_arguments', function ($arguments) {
    // Retrieve the subscriber by mobile number
    $subscriber = \WP_SMS\Newsletter::getSubscriberByMobile($arguments['to']);
    // Retrieve the user by phone number
    $user = \WP_SMS\Helper::getUserByPhoneNumber($arguments['to']);

    // If the subscriber exists, replace {display_name} with the subscriber's name
    if ($subscriber) {
    $arguments['msg'] = str_replace('{display_name}', $subscriber->name, $arguments['msg']);
    }
    // If the user exists, replace {display_name} with the user's display name
    elseif ($user) {
    $arguments['msg'] = str_replace('{display_name}', $user->display_name, $arguments['msg']);
    }

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

    Please consider the Delivery Method in the settings should be set on “Batch SMS Queue

    Best

    Thread Starter Mo

    (@nadhonar)

    I appreciate you.

    Regards

    Plugin Author Mostafa Soufi

    (@mostafas1990)

    Your welcome ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Patterns in content message’ is closed to new replies.