drewm / mailchimp-api

Super-simple, minimum abstraction MailChimp API v3 wrapper, in PHP
MIT License
1.99k stars 506 forks source link

How do we edit user tags? #286

Closed Mujan84 closed 4 years ago

Mujan84 commented 4 years ago

Hi, Im not sure if this is a missing feature here?

I would expect something like the code below to add the user to this Tag...

$MailChimp->post("lists/".LISTID."/members/$subscriber_hash/tags", [ 'tags' => [ ’Tag Name' => 'active' ] ]);

(This is my first post here on GitHub, so bear with me if im doing something wrong here. Thanks

roelofr commented 4 years ago

Sadly, you can't. It's not supported by the API.

Edit: Scratch that, I was utterly wrong.

POST /lists/{list_id}/members/{subscriber_hash}/tags

Add or remove tags from a list member. If a tag that does not exist is passed in and set as 'active', a new tag will be created.

So you'd call something like this:

$MailChimp->post("lists/" . LISTID . "/members/{$subscriber_hash}/tags", [
    "tags" => [
        [
            "name" => "Tag Name",
            "status" => "active",
        ]
    ]
]);
Mujan84 commented 4 years ago

Hi roelofr, Thanks, I also got this to work today, I would have posted the solution here tonight. I am now a happy user of this mailchimp-api... all is done on autopilot now:-)