Add Subscribers from Contact Form 7
Convert Contact Form 7 submissions into SMS subscribers.
Automatically add Contact Form 7 submissions to your SMS subscriber list.
Basic Integration
Add this code to your theme’s functions.php or a custom plugin:
function addNumberToSubscriberList($WPCF7_ContactForm)
{
$name = isset($_POST['your-name']) ? sanitize_text_field($_POST['your-name']) : "";
$mobile = isset($_POST['your-mobile']) ? sanitize_text_field($_POST['your-mobile']) : "";
if ($name && $mobile) {
\WP_SMS\Newsletter::addSubscriber($name, $mobile, '1'); // Replace '1' with your group ID
}
}
add_action('wpcf7_before_send_mail', 'addNumberToSubscriberList');
Configuration
- Replace
your-namewith your CF7 name field ID - Replace
your-mobilewith your CF7 phone field ID - Replace
'1'with your subscriber group ID
With Group Selection
Allow users to choose which group to join:
Step 1: Add Dropdown to CF7
[select group "1|News" "2|Sport" "3|General"]
Step 2: Update Code
function addNumberToSubscriberList($WPCF7_ContactForm)
{
$name = isset($_POST['your-name']) ? sanitize_text_field($_POST['your-name']) : "";
$mobile = isset($_POST['mobile-number']) ? sanitize_text_field($_POST['mobile-number']) : "";
$group = isset($_POST['group']) ? sanitize_text_field($_POST['group']) : "";
if ($name && $mobile) {
\WP_SMS\Newsletter::addSubscriber($name, $mobile, $group);
}
}
add_action('wpcf7_before_send_mail', 'addNumberToSubscriberList');
Hook Reference
| Hook | Description |
|---|---|
wpcf7_before_send_mail | Fires before CF7 sends confirmation email |
Related
- Elementor Form Integration - Elementor forms integration
- Manage Subscribers - View and manage subscribers
- Manage Groups - Create subscriber groups
Last updated: December 28, 2025