wp_sms_mi_pm_optin_notification

Control SMS opt-in status for Paid Memberships Pro users.

This filter allows you to control the SMS notification opt-in status for users in the Paid Memberships Pro integration.

Usage

add_filter('wp_sms_mi_pm_optin_notification', function ($optIn, $userId) {
    // Your logic here
    return $optIn;
}, 10, 2);

Parameters

ParameterTypeDescription
$optInboolCurrent opt-in status
$userIdintThe user ID

Example: Check User Meta for Opt-In

Only send SMS notifications to users who have explicitly opted in:

add_filter('wp_sms_mi_pm_optin_notification', function ($optIn, $userId) {
    $optInStatus = get_user_meta($userId, 'sms_opt_in_status', true);

    if (empty($optInStatus)) {
        return false;
    }

    return $optIn;
}, 10, 2);

How It Works

  1. The filter checks the user’s opt-in preference from their metadata
  2. If the metadata is empty, the function returns false
  3. This prevents SMS notifications from being sent to users who haven’t consented

Last updated: December 26, 2024