wp_sms_subscriber_form()

Display a subscriber form to collect SMS newsletter signups.

The wp_sms_subscriber_form() function displays a subscription form that allows visitors to sign up for SMS notifications on your WordPress site.

Syntax

wp_sms_subscriber_form( $args = [] );

Parameters

ParameterTypeRequiredDefaultDescription
$argsarrayNo[]Configuration options for the form

Available Options

OptionTypeDescription
titlestringForm title displayed above the fields
descriptionstringDescription text shown below the title
fieldsarrayCustom fields to add to the form

Custom Field Options

Each custom field in the fields array supports:

OptionTypeDescription
labelstringField label
descriptionstringHelp text for the field
typestringInput type (text, number, email, etc.)

Examples

Simple Example

Add a basic subscriber form to a page template:

<?php
get_header();
?>

<section id="primary" class="content-area">
    <main id="main" class="site-main">
        <?php wp_sms_subscriber_form(); ?>
    </main>
</section>

<?php
get_footer();

Advanced Example

Add a subscriber form with custom fields:

wp_sms_subscriber_form([
    'title' => 'SMS Newsletter',
    'description' => 'Subscribe to our SMS newsletter to get the latest news and updates delivered directly to your phone.',
    'fields' => [
        'age' => [
            'label' => 'Age',
            'description' => 'Please enter your age',
            'type' => 'number',
        ],
        'country' => [
            'label' => 'Country',
            'description' => 'Please select your country',
            'type' => 'text',
        ],
    ]
]);

Shortcode Alternative

You can also use the shortcode in the WordPress editor:

[wp_sms_subscriber_form]

Last updated: December 23, 2024