Skip to content

Conversation

@arnelap
Copy link
Contributor

@arnelap arnelap commented Dec 16, 2025

When submitting a new email I would get an error

  • tags[n] : This value should be of type string.

I decided to go with unsettling the tags from args, and submitting it separately.

Is this the right way though? Tbh I don't really understand how it did work with new subscribers before (and it did).

arnelap and others added 9 commits December 13, 2025 10:19
add_filter('mc4wp_subscriber_data', function (MC4WP_MailChimp_Subscriber $subscriber) {
    $subscriber->tags[] = ['name' => 'removethis', 'status' => 'inactive'];
    return $subscriber;
});
When submitting a new email I would get an error

- tags[n] : This value should be of type string.
@arnelap arnelap marked this pull request as ready for review December 16, 2025 10:15
@arnelap
Copy link
Contributor Author

arnelap commented Dec 16, 2025

ok, so i think what i could do for NEW subscribers is:

  • filter out all the status: inactive form the tags array (no need to remove tags for new subscriber)
  • convert the remaining "active" tags array[name] to a string "tags": ["tag1", "tag2", "tag3"]
  • That can then post to /lists/{list_id}/members without the second api call

That way the procedure stays close to what it has been doing so far.

However, updating subscribers the second API call is required though (and that's already how we did it, right?), I don't think there is any way around it, so maybe doing that same second call for new subscribers is actually the better way to do it to keep results consistent with future changes, and prevent the need to convert the tags to a string.

@dannyvankooten
Copy link
Member

dannyvankooten commented Jan 9, 2026

@arnelap I think the current approach is the cleanest (a separate call to the https://mailchimp.com/developer/marketing/api/list-member-tags/add-or-remove-member-tags/ endpoint), but:

  • The current version of this PR removes the merge with the existing member tags. I am not sure what the Mailchimp API does if you do a POST to the tags endpoint while only supplying some of the subscriber tags. In your tests, did this modify any existing tags not present in our API call? We want to make sure we are not affecting any existing tags in Mailchimp which may have been set by third-party code.

Answer: Maichimp does not modify any tags not supplied in the API call 🎉

  • Does the Mailchimp API respond with an error when trying to set a non-existing tag to inactive, as might be the case for new subscribers?

Answer: No, you can set unexisting tags to inactive without Mailchimp throwing an error 🎉

EDIT: Tested both cases, looks like we're good!

@dannyvankooten dannyvankooten merged commit 0f87558 into ibericode:main Jan 9, 2026
8 checks passed
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