Viewing 12 replies - 1 through 12 (of 12 total)
  • Thread Starter Dipak C. Gajjar

    (@dipakcg)

    Finally managed to get this working at my own. Updated pmpromc_subscribe function in pmpro-mailchimp.php

    function pmpromc_subscribe($list, $user)
    {
    	$options = get_option("pmpromc_options");
    
    	$api = pmpromc_getAPI();
    
    	$company = get_user_meta( $user->ID, 'company', true );
    	$job = get_user_meta( $user->ID, 'job', true );
    	$country = get_user_meta( $user->ID, 'Country', true );
    
    	$api_key = $options['api_key'];
    
    	try{
    		$mailchimp = new Mailchimp($api_key);
    		// $api->lists->subscribe($list, array("email"=>$user->user_email), apply_filters("pmpro_mailchimp_listsubscribe_fields", array("FNAME" => $user->first_name, "LNAME" => $user->last_name), $user), "html", $options['double_opt_in']);
    		// API Doc : subscribe(string apikey, string id, struct email, struct merge_vars, string email_type, bool double_optin, bool update_existing, bool replace_interests, bool send_welcome)
    		$mailchimp->lists->subscribe($list, array('email'=>$user->user_email), array('FNAME'=>$user->first_name, 'LNAME'=>$user->last_name, 'MMERGE3'=>$company, 'MMERGE4'=>$job, 'MMERGE5'=>$country), "html", false, true, false, true);
    	}
    	catch(Exception $e)
    	{
    		//we're okay with 200 class exceptions. throw others
    		$code = $e->getCode();
    		if($code < 200 || $code > 299)
    			wp_die($e->getMessage());
    	}
    }

    Hi there,

    I’m currently having the same issue here.

    Could you be more specific as to what solved the issue for you?

    Thanks

    Thread Starter Dipak C. Gajjar

    (@dipakcg)

    @bytal, Try to replace pmpromc_subscribe function in pmpro-mailchimp.php with the above one. It fixed the issue for me and if your issue is the same as I asked in the question, it should fix yours too.

    Didn’t work for me ??

    Basically, you’re just adding

    $api_key = $options[‘api_key’];

    but aside from custom fields, there’s no change.

    Anything else you might have changed?

    Same Problem here. Any News?

    Thread Starter Dipak C. Gajjar

    (@dipakcg)

    @bytal, @zulukatan, So you mean above solution didn’t work for you?

    @dipak C. Gajjar

    Actually not. No!

    The Mailchimp API reports that: (I Xed my IP)

    2015-02-22 15:10:10 GMT		nope	xxx.xxx.xxx.xxx	lists/list	json	0.055s	MailChimp-PHP/2.0.5	2.0	n/a
    2015-02-22 15:10:09 GMT		nope	xxx.xxx.xxx.xxx	helper/ping	json	0.008s	MailChimp-PHP/2.0.5	2.0	n/a
    2015-02-22 15:10:01 GMT		nope	xxx.xxx.xxx.xxx	lists/unsubscribe	json	0.047s	MailChimp-PHP/2.0.5	2.0	(232) Email_NotExists
    2015-02-22 15:10:01 GMT		nope	xxx.xxx.xxx.xxx	helper/ping	json	0.008s	MailChimp-PHP/2.0.5	2.0	n/a
    2015-02-22 15:10:01 GMT		nope	xxx.xxx.xxx.xxx	helper/ping	json	0.008s	MailChimp-PHP/2.0.5	2.0	n/a
    2015-02-22 15:10:01 GMT		nope	xxx.xxx.xxx.xxx	lists/subscribe	json	0.057s	MailChimp-PHP/2.0.5	2.0	(220) List_InvalidImport
    2015-02-22 15:10:01 GMT		nope	xxx.xxx.xxx.xxx	helper/ping	json	0.008s	MailChimp-PHP/2.0.5	2.0	n/a

    As you see it says Email not exists but it does.
    I already checkt the Variable that goes to the API.
    But i Guess thats just the API-Call for the Unsubscribe.

    Also it says “(220) List_InvalidImport” so it might be a Problem with the Format.
    But either yours or the Original Subscribe request are working.

    Ok, it seems that Mailchimp hast Problems to create a First Subscription.
    I manually added an Subscriber and if change the Level, he is unsubscribed of the current List.

    But No new entry in the new Level was created!

    It seems to work now thanks to your Changing.

    I think it′s caused by the double_opt_in, which i don′t unserstand why it is in the code original Code.

    All i needed to do is to change:

    "html", false, true, false, true instead of $options['double_opt_in']

    So the full entry needs to be this:
    $api->lists->subscribe($list, array('email'=>$user->user_email), array('FNAME'=>$user->first_name, 'LNAME'=>$user->last_name), "html", false, true, false, true);

    Thread Starter Dipak C. Gajjar

    (@dipakcg)

    2zulukatan, I am glad that it worked finally ??

    Hi @zulukatan,

    I’ve just tried that and still doesn’t work.

    Could it be that I have to make the change somewhere else too?

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Not adding user to Mailchimp list’ is closed to new replies.