php - MailChimp sending incorrect user IDs


EDIT: There's a chance I may have been a complete bonehead and mistook USER:UID for the member's ID when in fact it may be referring to the account admin ID. I have changed it to simply include the member's email address as the last URI segment. Is that an acceptable approach?

I'm setting up an EDM in MailChimp that includes a link to a website form. The URL is structured like so:*|LIST:UID|*/*|USER:UID|*

The idea is that some PHP on that page gets the member info using the list ID and the user ID in the API (3.0) endpoint for use in a cURL operation:

$url = '' . $listid . '/members/' . $userid;

The retrieved data would then pre-populate the form so that the user could edit the information and submit to 1) store the record of the submission locally in the CMS, and 2) send a PATCH command to the API.

This worked fine in my testing with a different MailChimp account, but when switching over to the production account, the*|USER:UID|* merge tag started sending incorrect hashes. I even changed the list but the ID stayed the same, and neither IDs were valid MD5 hashes.

To be clear, this is not an issue with authorization, I correctly changed the credentials (API key and username) and data center in the URL. If I manually enter a valid user ID into the URL the information is retrieved successfully. I simply can't get the correct user IDs to be embedded in the email.

Additionally, my initial testing using PUT instead of PATCH failed if the entered email address was not found in the list, sending back a message to use PUT (which I was).




Yeah, passing the email address back to your page is likely the best option for you here.




I know this question is old, but perhaps you were looking for*|UNIQID|* instead of*|USER:UID|*? According to MailChimp's documentation:

*|UNIQID|* Pulls in the $member->email->unique_id; (API function). If used in an email campaign, this tag will pull in your subscriber's unique ID. It can also be used to create unique links for subscribers.

The merge tag you were using,*|USER:UID|*, simply says:

*|USER:UID|* Displays the "u" parameter from your hosted Mailchimp audience forms.

While their documentation does not specify what the "u" parameter is, this other stack overflow answer to a related question mentions that it is an identifier for your account, which is exactly the same conclusion you came to in your question's edit :)

Personally, I prefer to pass unique IDs as opposed to email addresses for the sake of privacy. Some of my clients put a high value on privacy and security so we do not pass any personally identifiable information (PII) where it could be intercepted.

People are also looking for solutions to the problem: linux - Php version error when install composer


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.