Skip to content

Instantly share code, notes, and snippets.

@c2prods
Created April 27, 2017 02:25
Show Gist options
  • Select an option

  • Save c2prods/6c88089c9fa07427762347fb0a85d086 to your computer and use it in GitHub Desktop.

Select an option

Save c2prods/6c88089c9fa07427762347fb0a85d086 to your computer and use it in GitHub Desktop.
Mailchimp viral loop - Patch user
<?php
if (isset($_GET['r'])) {
$result = $MailChimp->get('lists/LIST_ID/members/'.$ref); //je retrouve le parrain grace au code de referral qui n'est autre que le md5 de son email
$refnbr = $result['merge_fields']['REFNBR']; //je retrouve son nombre de parrainages
$refnbr++; //j'incrémente ce nombre de 1
$MailChimp->patch('lists/LIST_ID/members/'.$_GET['r'], array( //je mets à jour les informations du parrain, toujours grace à son md5
'merge_fields' => array('REFNBR' => $refnbr) //et je changele merge tag REFNBR pour qu'il reflète le nouveau compte
));
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment