How to Automatically Add SMS Subscribers When Users Register on WordPress?

Updated on Oct 28, 2023

In the world of websites and online businesses, staying connected with your audience is key. One effective way to do this is by integrating SMS subscriptions into your WordPress user registration process. This allows you to automatically add new users as SMS subscribers, ensuring they receive important updates directly on their phones. In this guide, we’ll walk you through the easy steps of setting up this feature using the WP SM plugin.

Why Connect SMS Subscriptions with WordPress User Registration?

Before we jump into the “how,” let’s quickly talk about the “why.” Adding SMS subscriptions to your user registration process can bring great benefits:

  1. Instant Engagement: SMS messages are opened quickly, ensuring your messages reach users promptly.
  2. Personalized Interaction: You can address users by their names and share content relevant to their interests.
  3. Effortless Updates: Automated subscription ensures users receive updates without you manually sending messages.

Step-by-Step Guide to Integrating SMS Subscribers

Step 1: Install and Activate WPSMS Plugin

  • Log in to your WordPress admin dashboard.
  • Go to Plugins and click Add New.
  • Search for WP SMS, install the plugin, and activate it.

Step 2: Implement the Function

  • Inside your WordPress dashboard, go to Appearance and click Theme Editor.
  • Look for the functions.php file of your active theme.

Step 3: Add Code for Automated SMS Subscription

// Add this code to your functions.php file

function auto_subscribe_sms_on_registration($user_id) {
    $user_info = get_userdata($user_id);
    $name = $user_info->display_name;

    // Retrieve mobile number from user meta
    $mobile_meta_key = \WP_SMS\Helper::getUserMobileFieldName();
    $mobile_number = get_user_meta($user_id, $mobile_meta_key, true);

    $group_id = ''; // Set the group ID here

    if ($mobile_number && $group_id) {
        WPSms()->newsletter()::addSubscriber($name, $mobile_number, $group_id);
add_action('user_register', 'auto_subscribe_sms_on_registration');

Step 4: Save and Test

  • Save your changes to functions.php.
  • Test by registering a new user on your WordPress site.

Congratulations! You’ve successfully linked SMS subscriptions with your WordPress user registration using the WP SMS plugin.