Skip to content

Conversation

@arnelap
Copy link
Contributor

@arnelap arnelap commented Dec 13, 2025

Functional changes:
Changed the name of private function list_add_tags_to_subscriber to list_tags_to_subscriber
Changed private function merge_and_format_member_tags to accept a tag array with status active or inactive. (add/remove)
Removed array_unique(array_merge($mailchimp_tags, $new_tags), SORT_REGULAR); from merge_and_format_member_tags

Visual changes:
Added a "remove_subscriber_tags" option to Form > Settings that takes a comma separated list of tags to remove
Renamed the settings fields to "Add tags" and "Remove tags (was Add subscriber tags)

Unit tests:

  • Added the same unit test that existed for Add tags also to Remove tags

Testing:

  • I tested form submissions adding and removing 1 and multiple tags via the form setting(s).
  • Tested just adding, tested just removing, tested adding and removing at the same time with 1 tag each, added with multiple tags added and removed... (we could do the reverse?)
  • I tested form submissionadding and removing the same tag at the same time, removing is done later so it results in removing the tag

All the form submissions had the expected result of added tags being added, removed tags being removed and unmentioned tags remaining active.

  • I tested mc4wp_subscriber_data
//new format
add_filter('mc4wp_subscriber_data', function (MC4WP_MailChimp_Subscriber $subscriber) {
    $subscriber->tags[] = ['name' => 'remove this tag', 'status' => 'inactive'];
    $subscriber->tags[] = ['name' => 'another-removal', 'status' => 'inactive'];
    $subscriber->tags[] = ['name' => 'add this tag', 'status' => 'active'];
    $subscriber->tags[] = ['name' => 'also adding this tag']; //defaults to active
    return $subscriber;
});

//backwards compatible format still works too and defaults to status=active
add_filter('mc4wp_subscriber_data', function (MC4WP_MailChimp_Subscriber $subscriber) {
    $subscriber->tags[] = 'string-still-works';
    return $subscriber;
});

Tags with status inactive were removed if the subscriber had them, the tags not existing or the subscriber not having these tags assigned did not cause any error
The tags with status active and the tags without status explicitly set were added
Tags that are just a string instead of an array were added, for backwards compatibility.

add_filter('mc4wp_subscriber_data', function (MC4WP_MailChimp_Subscriber $subscriber) {
    $subscriber->tags[] = ['name' => 'removethis', 'status' => 'inactive'];
    return $subscriber;
});
@arnelap
Copy link
Contributor Author

arnelap commented Dec 13, 2025

added form setting to remove tags, so with that it should close #621

@arnelap arnelap marked this pull request as ready for review December 13, 2025 11:53
@dannyvankooten dannyvankooten merged commit 9b6bda4 into ibericode:main Dec 15, 2025
8 checks passed
@arnelap
Copy link
Contributor Author

arnelap commented Dec 15, 2025

Still need to add new code snippet examples

@arnelap arnelap deleted the remove-tags-option branch December 15, 2025 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants