Page 1 of 1

edition in "member profile" not updating mailchimp

PostPosted: July 4th, 2011, 10:23 am
by Leinad
If I login into my site then change something in my member profile form the changes are updated within s2member, but no Mail-chimp

is this "by design"?
if so, what can I do to manually code it?

Re: edition in "member profile" not updating mailchimp

PostPosted: July 4th, 2011, 11:24 am
by Cristián Lávaque
Have you told s2Member to update MailChimp when those changes happen? WP Admin -> s2Member -> API / List Server -> Automate Un-Subscribe/Opt-Outs :)

Re: edition in "member profile" not updating mailchimp

PostPosted: July 4th, 2011, 11:35 am
by cassel
Willl that work only for un-subscribe/opt-outs or also for updates?

Re: edition in "member profile" not updating mailchimp

PostPosted: July 4th, 2011, 11:57 am
by Cristián Lávaque
When an account's level changes on s2Member, it'll reflect on MailChimp depending on the integration you defined for levels-lists. Read the documentation there. :)

Re: edition in "member profile" not updating mailchimp

PostPosted: July 4th, 2011, 12:02 pm
by cassel
In the documentation there is a list of choices for "Process List Removals Automatically?". But instead of an account lever change, how about updating profile like email address? I dont see anything among the choices for that (unless it is not where it is supposed to show)

Re: edition in "member profile" not updating mailchimp

PostPosted: July 4th, 2011, 12:28 pm
by Cristián Lávaque
I don't think that kind of updates are integrated yet. Although they don't happen often, I can understand it'd be wanted. I'll mention it to Jason.

Re: edition in "member profile" not updating mailchimp

PostPosted: July 4th, 2011, 12:34 pm
by cassel
I think it would be great since the login widget that comes with the pro version does offer the option to the user to change his profile including the email. Since everything else is integrated with MailChimp, it would be a nice way to tie it all together! (more work for Jason! lol)

Re: edition in "member profile" not updating mailchimp

PostPosted: July 4th, 2011, 12:41 pm
by Jason Caldwell
Thanks for the great suggestion.
I'll see what I can do about this in a future release.

Re: edition in "member profile" not updating mailchimp

PostPosted: July 4th, 2011, 5:52 pm
by Leinad
hehe, that means that currently it's not possible :(
well, if my client wants it I'll post the code when is done, otherwise we'll wait for Jason's update :D

Re: edition in "member profile" not updating mailchimp

PostPosted: July 5th, 2011, 11:29 am
by Leinad
hey Jason, it seems my client wants this, which means I have to code it myself :(
can you point me in the right direction as to what files you think they might be modified?

thank you very much :)

Re: edition in "member profile" not updating mailchimp

PostPosted: July 5th, 2011, 7:04 pm
by Jason Caldwell
Gotchya. Thanks for the follow-up.

Yes, I would suggest this Hook for you.
ws_plugin__s2member_during_handle_profile_modifications

See: viewtopic.php?f=40&t=9605&src_doc_v=110605#src_doc_line_121

Re: edition in "member profile" not updating mailchimp

PostPosted: July 6th, 2011, 3:56 pm
by Leinad
Ok, I've returned with a temporary solution, I just added an action to the hook "ws_plugin__s2member_during_handle_profile_modifications"
Just paste that code in mu-plugins/s2-hacks.php :)

Code: Select all
add_action( 'ws_plugin__s2member_during_handle_profile_modifications','function_ws_plugin__s2member_during_handle_profile_modifications', 10, 1);

function function_ws_plugin__s2member_during_handle_profile_modifications($a)
{
    include_once $_SERVER['DOCUMENT_ROOT']."/feature/wp-content/plugins/s2member/includes/_xtnls/mailchimp/nc-mcapi.inc.php";
    $mcapi = new NC_MCAPI ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mailchimp_api_key"], true); 

    $mailchimp 
= array ("function" => __FUNCTION__, "func_get_args" => $a["_p"], "api_method" => "listUpdateMember");
    $mailchimp["list_id"] = "08e278e7b0";
    $email = $a["current_user"]->data->user_email;;

    $my_custom_elements = array(
        'MERGE0' => $a["_p"]["ws_plugin__s2member_profile_email"],
        'MERGE1' => $a["_p"]["ws_plugin__s2member_profile_first_name"],
        'MERGE2' => $a["_p"]["ws_plugin__s2member_profile_last_name"],
        'MERGE3' => $a["_p"]["ws_plugin__s2member_profile_merge3"],     //Job title
        'MERGE4' => $a["_p"]["ws_plugin__s2member_profile_merge4"],        //Organization Name
        'MERGE5' => $a["_p"]["ws_plugin__s2member_profile_merge5"],        //address1
        'MERGE6' => $a["_p"]["ws_plugin__s2member_profile_merge6"],        //address2
        'MERGE7' => $a["_p"]["ws_plugin__s2member_profile_merge7"],        //city
        'MERGE8' => $a["_p"]["ws_plugin__s2member_profile_merge8"],        //state
        'MERGE9' => $a["_p"]["ws_plugin__s2member_profile_merge9"],        //zip
        'MERGE10' => $a["_p"]["ws_plugin__s2member_profile_merge10"],        //phone
        'MERGE13' => $a["_p"]["ws_plugin__s2member_profile_merge13"]        //country
    );

    $mailchimp["merge_array"] = $my_custom_elements;


    $mailchimp["api_response"] = $mcapi->{$mailchimp["api_method"]}($mailchimp["list_id"], $email, $mailchimp["merge_array"], "html", false); 

     $mailchimp
["api_success"] = $success = true; 
    $mailchimp
["api_properties"] = $mcapi; 

//    echo "<pre>";    print_r($mailchimp);echo "</pre>";
    
} 


Note that is still missing a lot of features and some parts are hard coded because I only need it for this site, something more general needs to use other global variables or better coding standards :P

Re: edition in "member profile" not updating mailchimp

PostPosted: July 8th, 2011, 3:31 pm
by Jason Caldwell
Thanks for sharing this.
~ MUCH appreciated!