How to Integrate Third-Party Forms with Newsletter for WordPress
Content
Integrating your existing website forms with the 'Newsletter – Send awesome emails from WordPress' plugin is a common need. Many users want to capture newsletter subscriptions from forms built with popular plugins like Forminator, Gravity Forms, or WP Forms, or even from their theme's built-in subscription form. This guide explains the available methods and provides a code-based solution for custom integrations.
Why Direct Integrations Aren't Always Available
The free version of the 'Newsletter – Send awesome emails from WordPress' plugin offers built-in integrations for a limited number of form plugins, such as Contact Form 7, WPForms, and Ninja Forms. For many other form builders, including Forminator and Gravity Forms, a direct, out-of-the-box integration is not included in the free plugin. The development team has created commercial addons for some of these integrations, which is why you won't find the settings within the free plugin itself.
Common Integration Methods
Based on community discussions, there are a few primary ways to handle this:
- Commercial Addons: For specific integrations like WP Forms or Gravity Forms, the plugin's team offers dedicated commercial extensions. These are typically the simplest solution as they handle the field mapping and subscription process automatically.
- Shortcodes: As suggested by the plugin's support in one thread, a universal method is to use the plugin's built-in shortcodes to place a Newsletter subscription form anywhere on your site, bypassing the need for a third-party form integration.
- Custom Code Hook: For developers or users comfortable with code, the most flexible method is to use a WordPress action or filter hook provided by your form plugin to capture the submission data and then use the Newsletter plugin's API to create a subscription.
How to Create a Custom Integration with Code
This method involves two steps: hooking into your form plugin to get the submitted data, and then using that data to create a newsletter subscriber. The following example uses Forminator, but the logic can be adapted for any form plugin that provides hooks.
Step 1: Hook into Your Form Submission
First, you need to find the correct hook provided by your form plugin. For Forminator, this is the forminator_form_submit_field_data filter.
Step 2: Process the Data and Create a Subscription
Once you have the submitted data (like name and email), you can pass it to the Newsletter plugin's subscription method. The key function here is TNP::subscribe().
function my_custom_form_integration( $field_data_array, $form_id ) {
// Check if this is the specific form you want to integrate
if ($form_id != YOUR_TARGET_FORM_ID) {
return $field_data_array;
}
$subscriber_data = [];
// Loop through the submitted fields to find email and name
foreach ($field_data_array as $field) {
if ($field['name'] == 'email-1') { // Replace with your field name
$subscriber_data['email'] = $field['value'];
}
if ($field['name'] == 'name-1') { // Replace with your field name
$subscriber_data['name'] = $field['value'];
}
}
// If an email was found, try to subscribe the user
if (!empty($subscriber_data['email'])) {
// Get the Newsletter plugin's API class
$newsletter = Newsletter::instance();
// Prepare the subscription parameters
$params = [
'email' => $subscriber_data['email'],
'name' => $subscriber_data['name'] ?? '',
'status' => 'C', // 'C' for confirmed
'skip_confirm' => true // Skip the confirmation email
];
// Subscribe the user
$user = $newsletter->subscribe($params);
}
return $field_data_array;
}
add_filter( 'forminator_form_submit_field_data', 'my_custom_form_integration', 10, 2 );
Important Notes on This Code:
- Replace
YOUR_TARGET_FORM_IDwith the actual ID of your Forminator form. - Replace the field names (
email-1,name-1) with the exact name attributes from your specific form. - The
statusparameter set to'C'(Confirmed) andskip_confirmset totruewill immediately add the user to your list without sending a confirmation email. Remove these if you want to use the double opt-in process. - Always add this code to your child theme's
functions.phpfile or a custom site-specific plugin.
Addressing Spam Submissions
If you are integrating with a form and facing spam subscriptions, as mentioned in the Gravity Forms thread, the solution should be implemented at the form level, not the newsletter level. Ensure your third-party form has a CAPTCHA, honeypot, or other anti-spam measure enabled. The Newsletter plugin's custom code hook will process any data passed to it, so stopping spam at the source is crucial.
Conclusion
While direct integrations for every form plugin are not available in the free version, the 'Newsletter – Send awesome emails from WordPress' plugin provides the necessary tools for developers to build powerful custom integrations. Using the TNP::subscribe() method within a custom function hooked to your form's submission process is the most robust way to achieve this. Always test your code on a staging site before deploying it to your live environment.
Related Support Threads Support
-
No addon for Forminator forms, how to integrate?https://wordpress.org/support/topic/no-addon-for-forminator-forms-how-to-integrate/
-
How to use theme inbuilt subscription form with this plugin?https://wordpress.org/support/topic/how-to-use-theme-inbuilt-subscription-form-with-this-plugin/
-
Ajax submissionhttps://wordpress.org/support/topic/ajax-submission-7/
-
Gravity Forms Integration and Spamhttps://wordpress.org/support/topic/gravity-forms-integration-and-spam/
-
Ajax form(validation and response in the same page) – The Newsletter Pluginhttps://wordpress.org/support/topic/ajax-formvalidation-and-response-in-the-same-page-the-newsletter-plugin/
-
Adding captcha to formshttps://wordpress.org/support/topic/adding-captcha-to-forms/
-
Contac Form 7 und The Newsletter Pluginhttps://wordpress.org/support/topic/contac-form-7-und-the-newsletter-plugin/
-
Does it support gravityformshttps://wordpress.org/support/topic/does-it-support-gravityforms/
-
Ajax formhttps://wordpress.org/support/topic/ajax-form-2/
-
Integração wp formshttps://wordpress.org/support/topic/integracao-wp-forms/
-
connect with wp formhttps://wordpress.org/support/topic/connect-with-wp-form/
-
wp formshttps://wordpress.org/support/topic/wp-forms-53/
-
WP Forms-Integrationhttps://wordpress.org/support/topic/wp-forms-integration-3/