Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

dmytroshved's avatar

Mailchimp code review

Hello, could you review my code and tell me if I'm doing things properly?

The problem: The internet mainly explains how to set up a project, but doesn't explain how to actually work with it – for example, I need to notify a user about a successful subscription or profile update. I don't like the idea of adding a user to a list without their consent (some do this immediately after registration – I consider it unethical).

Additionally: I don't fully understand how to determine if a contact is subscribed. Mailchimp doesn't explicitly state this, so I'm relying on the "pending" or "subscribed" status.

Below you can see the code of my Livewire/NewsletterSubscription on screenshot and in text

Would be grateful for your help

Code:

0 likes
2 replies
martinbean's avatar

@dmytro_shved I’ve just written a comprehensive answer to your previous question here. Why do you have multiple questions around the same topic?

I wouldn’t over-complicate things. If a user is entering their email address in an input to subscribe, and the request was successful, just return a success message. If Mailchimp requires them to verify their email address before actually being added to the list, then the user will get that email and can click the link. There’s no real reason to differentiate between “pending” and actually subscribed.

Same if a user who is already subscribes enters their email. They may have just forgotten they were already subscribed, so if they start receiving emails from you, they’re not exactly going to complain, are they? Since their intention was to receive them any way.

dmytroshved's avatar

@martinbean Thank you for reply, actually I was testing some approaches and finished this one right before you posted your answer

1 like

Please or to participate in this conversation.