Skip to content

Instantly share code, notes, and snippets.

@gdnwebmedia
Last active February 18, 2021 22:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gdnwebmedia/7e4c85b0e966526f2484f87defbdfae9 to your computer and use it in GitHub Desktop.
Save gdnwebmedia/7e4c85b0e966526f2484f87defbdfae9 to your computer and use it in GitHub Desktop.
Using the Mailchimp Integration already included in Forminator Pro. This scripts allows us to add one or multiple tags to a Forminator Pro form.
<?php
/*
Name: forminator-send-tags-via-form.php
Description: Sends Mailchimp Tags via Forminator Pro
Source: Konstantinos @
URL: https://premium.wpmudev.org/forums/topic/can-i-send-mailchimp-tags-via-form/#post-3624257
Using the Mailchimp Integration already included in Forminator Pro. This scripts allows us to add one or multiple tags to a Forminator Pro form.
install this code in the /mu-plugins folder
In your form have a Hidden Field and add the values as a comma separated list "tag_one,tag_two" ( if you want multiple ), or single if you want 1 tag only "tag_one".
You'll have to replace the "hidden-1" value from $_REQUEST['hidden-1'], into the ID that your hidden field has in the form.
And the tags should be now working
*/
add_filter('forminator_addon_mailchimp_api_request_data', function ($request_data, $verb, $path) {
$form_id = $_REQUEST['form_id'];
$tag = sanitize_text_field($_REQUEST['hidden-1']);
$tags = explode(',', $tag);
if (is_array($request_data)) {
if (empty($request_data['fields'])) {
$request_data['tags'] = $tags;
}
}
return $request_data;
},15,3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment