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
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
$args | array | No | [] | Configuration options for the form |
Available Options
| Option | Type | Description |
|---|---|---|
title | string | Form title displayed above the fields |
description | string | Description text shown below the title |
fields | array | Custom fields to add to the form |
Custom Field Options
Each custom field in the fields array supports:
| Option | Type | Description |
|---|---|---|
label | string | Field label |
description | string | Help text for the field |
type | string | Input 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]
Related
- wp_sms_add_subscriber - Action hook triggered when a user subscribes
Last updated: December 23, 2024