As i am looking at this, i am just a bit unsure of the sequence of the steps. What comes first? Do i have to set the MERGE var in MailChimp first and then create the hack file? I think i can follow those instructions, but just not sure of the order. Could you clarify that?
Yes, that is correct. Otherwise, s2Member's communication with the MailChimp API will fail, because s2Member ( with your hack file ), would be trying to send data to your MailChimp account, which MailChimp is not yet configured to receive.
Also, re-re-reading the instructions for that hack file, you mention S2_CUSTOM. How do i get more than one custom var? If i have product A and product B and product C and a customer can get any one of them or any combination of 2 (or 3) even if not at the same time, how are they identified?
For the benefit of other readers, I'll re-post this in it's entirely,
and I'll modify it a bit to give you an example of adding multiple MERGE vars for each Customer.You will probably want to seek assistance from a developer to complete this, but none the less, here is a quick example for you. This example shows how you might add custom MERGE fields into the existing defaults that s2Member already supplies with each call to the MailChimp API.
Create this directory and file:/wp-content/mu-plugins/s2-hacks.php
- Code: Select all
<?php
add_filter("ws_plugin__s2member_mailchimp_merge_array", "my_filter");
function my_filter($merge, $vars)
{
$user_id = $vars["user_id"];
$user_custom = get_user_option("s2member_custom", $user_id);
$user_role = get_user_field ("s2member_access_role", $user_id);
$my_custom_merge_vars = array("S2_CUSTOM" => $user_custom, "S2_ROLE" => $user_role);
return array_merge($merge, $my_custom_merge_vars);
}
?>
* Based on this example, you would first need to add two new MERGE fields to your MailChimp list, with the names:
S2_CUSTOM and
S2_ROLE. See also this s2Member API Function:
get_user_field(), which might be helpful when collecting certain details about a User/Member:
viewtopic.php?f=40&t=12453&src_doc_v=111003#src_doc_get_user_field%28%29Another silly question: if i already created a hack file for another task, do i just add to the same file for this?
Nope, you can put everything in one s2-hacks.php file. Or if you prefer, split things up into one file for each type of hack. The name "s2-hacks.php" is NOT required. Just make sure your file(s) have a PHP extension.
Then, maybe something for down the road, but if the user is not automatically updated (like if it is an existing user) in WP, will this variable STILL be updated in MailChimp? Meaning does the information go to MailChimp right at registration/payment or only when it comes back to s2Member? (meaning that if s2M does not update it, MailChimp wont either)
Right, this information is only processed during registration, and NOT during Profile updates. We're working on this however, for a future release.