MailerLite Integration for SnapForm WordPress Plugin submissions.
This WordPress plugin adds subscribers to MailerLite triggered by SnapForms submission creation events. It supports multiple SnapForms forms, each with its own mapping, consent requirements, and target groups, configured via a JSON file stored outside the plugin directory.
- Per-form configuration (multiple forms supported)
- Field mapping from SnapForms fields to MailerLite custom fields
- Consent enforcement (one or more consent fields required)
- Group assignment on subscribe
- Config stored outside the plugin (safer for updates)
- Graceful error handling (errors logged via
error_log)
- WordPress
- SnapForms plugin (to emit submission events)
- A MailerLite API token
- On each SnapForms submission, the plugin receives
snapforms.submission.new. - It looks up the form's config by
id_form. - If required consents are present, it builds the MailerLite payload using your field mappings and submits it to MailerLite.
- Copy this plugin folder into
wp-content/plugins/. - Activate the plugin from the WordPress admin.
- On first activation, if no config exists, the plugin generates a sample config file at:
wp-content/snapforms/addons/mailerlite/config.json - Edit the config file to add your real data (API token, form IDs, field mappings, consent fields, and groups).
The configuration file is stored outside the plugin, so updates don’t overwrite your settings:
- Path:
wp-content/snapforms/addons/mailerlite/config.json
Top-level object with a forms array. Each entry corresponds to a SnapForms form and must include an id_form string.
id_form(string): The SnapForms form ID this config applies to.api_token(string): Your MailerLite API token.fields(object): Map of SnapForms field IDs → MailerLite field names.required_consents(array): List of SnapForms field IDs that must have consentdt_given.groups(array): Array of MailerLite group IDs to add the subscriber to.settings(object): Optional settings.timeout(number): HTTP timeout in seconds (default: 30).
{
"forms": [
{
"id_form": "SNAPFORMS_FORM_ID",
"api_token": "MAILERLITE_API_TOKEN",
"fields": {
"SNAPFORMS_FIELD_UUID_A": "MAILERLITE_FIELD_NAME_A",
"SNAPFORMS_FIELD_UUID_B": "MAILERLITE_FIELD_NAME_B",
"SNAPFORMS_FIELD_UUID_C": "MAILERLITE_FIELD_NAME_C"
},
"required_consents": [
"SNAPFORMS_FIELD_UUID"
],
"groups": [
"MAILERLITE_GROUP_ID"
],
"settings": {
"timeout": 30
}
}
]
}For each mapped SnapForms field, the plugin attempts to read, in order:
sub_data.labelsub_data.valuesub_data.textIf none are present, an empty string is sent.
- Each field UUID in
required_consentsmust be a consent checkbox field, containingsub_data.consent.dt_given(non-empty) in the submission. If any required consent is missing, the subscriber is not added.
- Add an entry to the
formsarray for each SnapForms form you want to integrate. - The plugin indexes these entries internally by
id_formfor fast lookups.
- API request failures and validation errors are logged with
error_log. - No admin notices are displayed by default to avoid noise on normal submissions.
- Keep your
api_tokenout of version control. - Never commit real tokens to public repositories.
- Ensure
wp-content/snapforms/addons/mailerlite/is writable by WordPress to allow initial sample config creation.
- Removing the plugin does not delete the external config directory.
- If you need to remove configuration, delete
wp-content/snapforms/addons/mailerlite/config.jsonmanually.
- Hook consumed:
snapforms.submission.new - Core client:
includes/MailerLiteClient.php - The client supports the current JSON shape with
fieldsand optionalsettings.timeout. It can be extended to support new keys (e.g., global defaults) with minimal changes.
- Initial public release: per-form configs, consent enforcement, external config storage, sample config generation on activation.
- Author: Eduardo Esteves
- Project page: https://edluis97.github.io/