Add Subscribers from Gravity Forms

Automatically add Gravity Forms submissions to SMS subscribers.

Automatically add contacts from Gravity Forms submissions to your SMS subscriber list.

Implementation

Add this code to your theme’s functions.php file:

/**
 * Add Gravity Forms entry to SMS subscribers
 *
 * @param array $entry Form entry data
 * @param array $form Form configuration
 */
function addNumberToSubscriberList($entry, $form)
{
    $name    = $entry[1]; // Name field ID
    $mobile  = $entry[2]; // Phone field ID
    $groupId = $entry[3]; // Group field ID (optional)

    \WP_SMS\Newsletter::addSubscriber($name, $mobile, $groupId, '1');
}
add_action('gform_after_submission', 'addNumberToSubscriberList', 10, 2);

Configuration

Step 1: Find Field IDs

  1. Edit your Gravity Form
  2. Click on each field
  3. Note the Field ID shown in the field settings

Step 2: Update Code

Replace the field IDs in the code with your actual IDs:

$name    = $entry[1]; // Replace 1 with your Name field ID
$mobile  = $entry[2]; // Replace 2 with your Phone field ID
$groupId = $entry[3]; // Replace 3 with your Group field ID

Step 3: Test

  1. Submit the form
  2. Go to SMS → Subscribers
  3. Verify the new subscriber appears

Parameters

ParameterDescription
$nameSubscriber name from form
$mobilePhone number from form
$groupIdGroup ID to assign subscriber
'1'Status: 1 = active, 0 = inactive

Without Group Selection

If your form doesn’t have a group field, use a fixed group ID:

function addNumberToSubscriberList($entry, $form)
{
    $name   = $entry[1];
    $mobile = $entry[2];

    \WP_SMS\Newsletter::addSubscriber($name, $mobile, 1, '1'); // Group ID 1
}
add_action('gform_after_submission', 'addNumberToSubscriberList', 10, 2);

Target Specific Form

To only add subscribers from a specific form:

function addNumberToSubscriberList($entry, $form)
{
    // Only process form ID 5
    if ($form['id'] != 5) {
        return;
    }

    $name   = $entry[1];
    $mobile = $entry[2];

    \WP_SMS\Newsletter::addSubscriber($name, $mobile, 1, '1');
}
add_action('gform_after_submission', 'addNumberToSubscriberList', 10, 2);

Last updated: December 28, 2025