Advertisement:

Author Topic: Integration of Mailchimp  (Read 1541 times)

Abhi

  • Jr. Member
  • **
  • Posts: 78
  • Love what you do :)
Integration of Mailchimp
« on: June 14, 2016, 09:19:58 pm »
HI guys

here is the function currently it works only with contact user (contact publisher on item sidebar)

place your api key and listid and you are good to go
place below function in functions.php of theme file and extact zip file and place
MCAPI.class.php file in your active folder

function add_to_mailchimp(){

require_once 'MCAPI.class.php';

 
// Submit subscriber data to MailChimp
// For parameters doc, refer to: http://apidocs.mailchimp.com/api/1.3/listsubscribe.func.php

$email = $_REQUEST['yourEmail'];
$fname = $_REQUEST['yourName'];
$lname = " ";
 $mailchimp_apikey = Params::getParam('apikey');
 $mailchimp_listid = Params::getParam('listid');
$api = new MCAPI( $mailchimp_apikey);
$merge_vars = array('FNAME'=>$fname, 'LNAME'=>$lname);
$retval = $api->listSubscribe( $mailchimp_listid, $email,$merge_vars, 'html', false, true );



}

osc_add_hook('pre_item_contact_post','add_to_mailchimp');
« Last Edit: June 15, 2016, 01:38:54 pm by Abhi143u11 »

gstar

  • Full Member
  • ***
  • Posts: 153
Re: Integration of Mailchimp
« Reply #1 on: July 02, 2016, 03:10:29 pm »
Can we adapt this to include double opt-in?

Abhi

  • Jr. Member
  • **
  • Posts: 78
  • Love what you do :)
Re: Integration of Mailchimp
« Reply #2 on: July 02, 2016, 03:13:31 pm »
Yes you can just  add $api->listSubscribe( $mailchimp_listid, $email,$merge_vars, 'html', false, true );
one more true
$api->listSubscribe( $mailchimp_listid, $email,$merge_vars, 'html', false, true,true );

else check listSubscribe Function in the file attached

thats it will work for double optin
« Last Edit: July 02, 2016, 03:15:30 pm by Abhi143u11 »

gstar

  • Full Member
  • ***
  • Posts: 153
Re: Integration of Mailchimp
« Reply #3 on: July 29, 2016, 09:02:54 pm »
Where should I place the file MCAPI.class.php?

Abhi

  • Jr. Member
  • **
  • Posts: 78
  • Love what you do :)
Re: Integration of Mailchimp
« Reply #4 on: July 30, 2016, 09:39:19 am »
Where should I place the file MCAPI.class.php?


if you are using plugin than place in plugin main folder


and


for theme place it in theme folder

gstar

  • Full Member
  • ***
  • Posts: 153
Re: Integration of Mailchimp
« Reply #5 on: July 30, 2016, 12:15:47 pm »
OK thanks.

I placed it in /public_html/oc-content/themes/bender.

The contact form sends without error but nothing happens on the mailing list and the user does not receive the opt in email to confirm registration on the mailing list.

Any ideas?

Abhi

  • Jr. Member
  • **
  • Posts: 78
  • Love what you do :)
Re: Integration of Mailchimp
« Reply #6 on: July 30, 2016, 03:06:20 pm »
Hi


update  is the syntax as below it




[size=0px]$api->listSubscribe( $mailchimp_listid, $email,$merge_vars, 'html', false, true,true );[/size]
[/size]
[/size]This will send the double opt in mail[size=0px]

gstar

  • Full Member
  • ***
  • Posts: 153
Re: Integration of Mailchimp
« Reply #7 on: July 30, 2016, 03:51:02 pm »
Strange, nothing is happening.

See attached my functions.php which is inside bender theme.

Abhi

  • Jr. Member
  • **
  • Posts: 78
  • Love what you do :)
Re: Integration of Mailchimp
« Reply #8 on: July 30, 2016, 04:26:38 pm »
Use this and first delete user you want to subscribe to verify from mailchimp list

gstar

  • Full Member
  • ***
  • Posts: 153
Re: Integration of Mailchimp
« Reply #9 on: July 30, 2016, 04:56:55 pm »
I replaced it but still nothing happens.

The list is currently empty.