MailChimp REST Api V3 exposes methods that allows you to add, manage members of a specific MailChimp list. The following code snippet help you to add a new subscriber to MailChimp List.

class ST_Newsletter_Plugin {
	public function __construct(){ 
	function subscribe($user_id, $user_email){
		//get api_key and list id from admin settings
		$api_key = "c8d8c17ae54aui8ujnj43343-us9";
		$list_id = "2d9e113i8hm";
		$mailChimp = new MailChimp($api_key);
		$result = $mailChimp->post("lists/$list_id/members", [
			'email_address' => $user_email,
			'status'=> 'subscribed'

		if ($mailChimp->success()) {
		    echo "success";
		} else {
		   echo "fail";


You can download “MailChimp.php” from GitHub.

Tagged in : #PHP


Please note: We reserve the right to delete comments that contains snarky remarks, offensive or off-topic. To know more read our comments policy.