Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Struggling to remove a tag from a user #300

Open
Gigamick opened this issue Jul 22, 2020 · 5 comments
Open

Struggling to remove a tag from a user #300

Gigamick opened this issue Jul 22, 2020 · 5 comments

Comments

@Gigamick
Copy link

I can add tags successfully but when I try to delete a tag from a user I get an error.

Here's my code:

$m = new MailChimp($apiKey);
        $m->delete("lists/".$listId."/members/".$memberId."/tags", [
            'tags' => [
                [
                    'name' => $tag,
                    'status' => 'active',
                ],
            ]
        ]);

The error I'm getting is

ErrorException: Undefined offset: 1 in file /Users/mick/repos/sbx/vendor/drewm/mailchimp-api/src/MailChimp.php on line 340

Thanks 🤘

@Gigamick
Copy link
Author

@drewm sorry to tag you directly. Do you have any insight into what's wrong here?

@sugus67
Copy link

sugus67 commented Sep 29, 2020

From my understandings of what I find on https://mailchimp.com/developer/api/marketing/list-member-tags/ the only difference between adding or deleting would be setting the status to active or inactive.

But when I try to add a tag with this code:

$result = $MailChimp->post("lists/${list_id}/members/${subscriber_hash}/tags",[
'name' => 'TestTag',
'status' => 'active',
]);

I don't get an error but the tag doesn't get added.
Could you tell me how you did it to add a tag? Maybe just changing 'active' to 'inactive' would solve your problem.
Thanks in advance!

@noproblematall
Copy link

noproblematall commented Oct 14, 2020

hey, @Gigamick, @sugus67
you can try this.

$result = $MailChimp->post("lists/$list_id/members/$subscriber_hash/tags", [
    'tags' => array(
         [
            'name' => 'tagname',
            'status' => 'inactive'
         ],
        [
           'name' => 'othertag',
            'status' => 'active'
        ]
     )
]);

@mcrnbrck
Copy link

mcrnbrck commented Nov 20, 2020

You can add a tag like this:

$result = $MailChimp->post("lists/$list_id/members/$subscriber_hash/tags", [
'tags' => array( 'your tag')
]);

But I am struggling to remove tags too.

@Trekels
Copy link

Trekels commented Dec 8, 2021

For future reference.

As listed in the mailchimp api docs a status property has to be passed along with the tag name.

$MailChimp->post("lists/$list_id/members/$subscriber_hash/tags", [
  'tags' => [
        [
            'name' => 'your-tag-name',
            'status' => 'inactive',              // Active will add the tag, inactive will remove the tag
        ]
    ]
]);

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

No branches or pull requests

5 participants