Skip to content

wp_sms_api_message_content

تعديل محتوى رسالة SMS قبل الإرسال عبر REST API.

يتيح لك فلتر wp_sms_api_message_content تعديل محتوى رسالة SMS قبل الإرسال عبر REST API الخاص بـ WSMS.

الصيغة

add_filter('wp_sms_api_message_content', 'your_callback', 10, 2);

المعاملات

المعاملالنوعالوصف
$messagestringنص الرسالة الأصلي
$argsarrayمعاملات الطلب المُمررة إلى SMS API

القيمة المُرجعة

يجب أن تُرجع نص الرسالة المُعدّل.

أمثلة

إضافة تعليمات إلغاء الاشتراك

add_filter('wp_sms_api_message_content', function($message, $args) {
    if (!empty($args['group_ids'])) {
        $message .= "\nReply STOP to unsubscribe from this group.";
    } else {
        $message .= "\nReply STOP to unsubscribe.";
    }

    return $message;
}, 10, 2);

إضافة طابع زمني

add_filter('wp_sms_api_message_content', function($message, $args) {
    $timestamp = date('Y-m-d H:i:s');
    $message .= "\n[Sent: {$timestamp}]";

    return $message;
}, 10, 2);

تنسيق مشروط

add_filter('wp_sms_api_message_content', function($message, $args) {
    if (strpos($message, 'SPECIALOFFER') !== false) {
        $message = "🎉 " . $message . " 🎉";
    }

    return $message;
}, 10, 2);

إضافة العلامة التجارية للمرسل

add_filter('wp_sms_api_message_content', function($message, $args) {
    return "[MyStore] " . $message;
}, 10, 2);

تحذير حد الأحرف

add_filter('wp_sms_api_message_content', function($message, $args) {
    if (strlen($message) > 160) {
        error_log("SMS exceeds 160 chars: " . strlen($message));
    }

    return $message;
}, 10, 2);

حالات الاستخدام

  • إضافة تعليمات إلغاء الاشتراك للامتثال
  • إلحاق الطوابع الزمنية للتتبع
  • إضافة العلامة التجارية أو بادئة للرسائل
  • تطبيق تنسيق مشروط بناءً على المحتوى
  • تسجيل أو التحقق من طول الرسالة

الفلاتر ذات الصلة

الفلترالوصف
wp_sms_msgتعديل محتوى الرسالة (عام)
wp_sms_toتعديل أرقام المستلمين
wp_sms_fromتعديل معرّف المرسل

ذات صلة

آخر تحديث: ٢٣ ديسمبر ٢٠٢٤