50% OFF Limited time deal!

Unsubscribe/Opt-Out mobile number by URL

Updated on Oct 21, 2021

The subscribers can unsubscribe/Opt-Out from the SMS newsletter by URL https://yourdomain.com/?wpsms_unsubscribe=01111111111

How to send the Unsubscribe/Opt-Out link in welcome SMS?

You may include the Unsubscribe/Opt-Out link automatically in the welcome SMS? use the below filter in your functions.php theme.

/**
 * Modify the welcome SMS message
 *
 * @param $message
 * @param $mobile
 * @return string
 */
function sendUnSubscribeUrlInWelcomeSMS($message, $mobile)
{
    $message .= sprintf('\r\n Unsubscribe link: %s', WPSms()->newsletter()->generateUnSubscribeUrlByNumber($mobile));

    return $message;
}

add_action('wpsms_welcome_sms_message', 'sendUnSubscribeUrlInWelcomeSMS', 10, 2);

 

How to customize the unsubscribe URL:

You may modify the ?wpsms_unsubscribe query string in the URL by using the below filter in your functions.php theme.

/**
 * Modify to unsubscribe query string
 *
 * @param $queryString
 * @return string
 */
function modifyUnSubscribeQueryString($queryString)
{
    $unsubscribe = 'unsubscribe';

    return $unsubscribe;
}

add_filter('wpsms_unsubscribe_query_string', 'modifyUnSubscribeQueryString');