Automatically Subscribe Ultimate Member Users to SMS Newsletter Upon Registration

Updated on Jun 15, 2025

Adding every newly registered user to your SMS list ensures you can reach them instantly with announcements, offers, or important updates. In this guide, you’ll learn how to hook into Ultimate Member’s registration flow and automatically subscribe new users to a WP SMS newsletter group.

Prerequisites

Before diving in, make sure you have the following in place:

  • WP SMS plugin installed and activated
  • Ultimate Member (UM) plugin installed and activated
  • At least one SMS Group configured under WP SMS > Groups (note its Group ID)

Understanding the Hook

Ultimate Member fires the um_registration_complete action immediately after a user finishes the registration form. It provides:

  • $user_id: the new user’s numeric ID
  • $args: an associative array of submitted fields (e.g. first_name, phone, user_email, etc.)

By tapping into this hook, we can capture the user’s phone number and pass it to WP SMS.

Implementation

Add the following code to your theme’s functions.php:

add_action( 'um_registration_complete', 'wp_sms_subscribe_on_registration', 10, 2 );
function wp_sms_subscribe_on_registration( $user_id, $args ) {
    $first_name_field = 'first_name'; // ← change this to your actual first name field name
    $phone_field = 'phone'; // ← change this to your actual phone field name
    
    $name = ! empty( $args[ $first_name_field ] )
        ? sanitize_text_field( $args[ $first_name_field ] )
        : "um_user_{$user_id}";

    $mobile = preg_replace( '/\D+/', '', $args[ $phone_field ] ?? '' );
    if ( empty( $mobile ) ) {
        return; // No phone provided, so skip subscription
    }

    $group_id = 1;  // ← change this to your actual group ID

    // 4) Attempt to add the subscriber
    try {
        \WP_SMS\Newsletter::addSubscriber( $name, $mobile, $group_id );
    } catch ( Exception $e ) {
        error_log( "WP SMS subscribe failed for user {$user_id}: " . $e->getMessage() );
    }
}

With this in place, every new Ultimate Member signup will automatically land in your SMS newsletter.