From a3ed6ed6bdff697df168c693ee68e804bacee86c Mon Sep 17 00:00:00 2001 From: Arne Lap Date: Tue, 20 Jan 2026 11:33:15 +0100 Subject: [PATCH] Demonstrate new tag format with active and inactive status and clarified form ID for CF7 was $subscriber->tags[] = 'My tag'; now $subscriber->tags[] = ['name' => 'Another tag', 'status' => 'active']; $subscriber->tags[] = ['name' => 'Remove this tag', 'status' => 'inactive']; as for the CF7 ID, CF7 shows some internal ID that is NOT the post ID so that can be confusing. --- sample-code-snippets/forms/subscriber-tags.php | 18 ++++++++++++++++-- .../contact-form-7/different-tag.php | 11 +++++++++++ .../woocommerce/woocommerce-subscriber-tag.php | 17 ++++++++++++++++- 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/sample-code-snippets/forms/subscriber-tags.php b/sample-code-snippets/forms/subscriber-tags.php index 8c5946cb..b4241998 100755 --- a/sample-code-snippets/forms/subscriber-tags.php +++ b/sample-code-snippets/forms/subscriber-tags.php @@ -1,13 +1,27 @@ tags[] = 'My tag'; return $subscriber; }); + +//This will remove the tag "My tag" from all new subscribers added by the plugin. +add_filter('mc4wp_subscriber_data', function (MC4WP_MailChimp_Subscriber $subscriber) { + $subscriber->tags[] = ['name' => 'My Tag', 'status' => 'inactive']; + return $subscriber; +}); + + +//You can add and remove multiple tags at once. +add_filter('mc4wp_subscriber_data', function (MC4WP_MailChimp_Subscriber $subscriber) { + $subscriber->tags[] = ['name' => 'My Tag', 'status' => 'active']; + $subscriber->tags[] = ['name' => 'Another tag', 'status' => 'active']; + $subscriber->tags[] = ['name' => 'Remove this tag', 'status' => 'inactive']; + return $subscriber; +}); diff --git a/sample-code-snippets/integrations/contact-form-7/different-tag.php b/sample-code-snippets/integrations/contact-form-7/different-tag.php index 331c6226..bc7b55ab 100755 --- a/sample-code-snippets/integrations/contact-form-7/different-tag.php +++ b/sample-code-snippets/integrations/contact-form-7/different-tag.php @@ -1,5 +1,16 @@ tags[] = 'ES'; diff --git a/sample-code-snippets/integrations/woocommerce/woocommerce-subscriber-tag.php b/sample-code-snippets/integrations/woocommerce/woocommerce-subscriber-tag.php index c927aa31..74a6f6dc 100755 --- a/sample-code-snippets/integrations/woocommerce/woocommerce-subscriber-tag.php +++ b/sample-code-snippets/integrations/woocommerce/woocommerce-subscriber-tag.php @@ -1,11 +1,26 @@ tags[] = 'My tag'; return $subscriber; }); + + +//Remove the tag "My tag" from all new subscribers added using WooCommerce Checkout integration. +add_filter('mc4wp_integration_woocommerce_subscriber_data', function (MC4WP_MailChimp_Subscriber $subscriber) { + $subscriber->tags[] = ['name' => 'My tag', 'status' => 'inactive']; + return $subscriber; +}); + +//Add the tag "My tag" to all new subscribers added using WooCommerce Checkout integration while removing the "Remove me" tag. +add_filter('mc4wp_integration_woocommerce_subscriber_data', function (MC4WP_MailChimp_Subscriber $subscriber) { + $subscriber->tags[] = ['name' => 'My tag', 'status' => 'active']; + $subscriber->tags[] = ['name' => 'Remove me', 'status' => 'inactive']; + return $subscriber; +});