Auto-Subscribe Users on Registration

Automatically add users to SMS subscribers when they register.

Automatically subscribe users to your SMS newsletter when they register on your WordPress site.

Benefits

  • Instant Engagement - SMS messages are opened quickly, ensuring prompt delivery
  • Personalized Interaction - Address users by name and share relevant content
  • Effortless Updates - Users receive updates without manual intervention

Implementation

Add this code to your theme’s functions.php file or a custom plugin:

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

    $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');

Configuration

  1. Replace $group_id = '' with your actual group ID
  2. Find your group ID in SMS → Groups

How It Works

  1. User registers on your WordPress site
  2. The user_register hook fires
  3. Code retrieves user’s name and mobile number
  4. User is added to the specified SMS subscriber group

Requirements

  • WP SMS plugin installed and active
  • Mobile number field configured in user registration
  • At least one subscriber group created

Last updated: December 28, 2025