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
- Replace
$group_id = ''with your actual group ID - Find your group ID in SMS → Groups
How It Works
- User registers on your WordPress site
- The
user_registerhook fires - Code retrieves user’s name and mobile number
- 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
Related
- Manage Subscribers - View and manage subscribers
- Manage Groups - Create subscriber groups
- Mobile Field Source - Configure mobile field collection
Last updated: December 28, 2025