Updating Opt-In Status for SMS Notifications in WP SMS Membership Integrations

Updated on Jun 19, 2024

This guide details how to add a filter hook to manage the opt-in status for SMS notifications in the WP SMS Membership Integrations addon for Paid Memberships Pro.

Adding the Opt-In Hook

To update the opt-in status for SMS alerts, add the following code to your theme’s functions.php file or a custom plugin:

// Add filter to check user's opt-in status for SMS notifications
add_filter('wp_sms_mi_pm_optin_notification', function ($optIn, $userId) {
    // Retrieve the opt-in status from user meta
    $optInStatus = get_user_meta($userId, 'sms_opt_in_status', true);

    // If the opt-in status is empty, set optIn to false
    if (empty($optInStatus)) {
        $optIn = false;
    }

    return $optIn;
}, 10, 2);

Steps to Implement

  1. Copy the Code: Paste the provided code into your theme’s functions.php file or a custom plugin.
  2. Adjust Meta Key: Ensure the meta key 'sms_opt_in_status' matches the key used in your user meta data for storing SMS opt-in status.