wpsharks / s2member

s2Member® Framework (membership management for WordPress®).
64 stars 36 forks source link

MailChimp transition affects non-s2 Interest Groups #757

Open ghost opened 8 years ago

ghost commented 8 years ago

My MailChimp list has an Interest Group, "Member Level," for s2 member membership levels. s2member is configured to transition levels as people move from level to level. That works GREAT. Thank you!

However, I have another Interest Group in my list, "Acanthus Book," (and more to come). Values in that group get reset when transitions occur. Not good!

The two groups look like this: image

I would like the s2 transitions to continue happening, but without touching the "Acanthus Book" group.

Yes, I suspect you might advise separating the two groups into separate lists, which is what we have now. However, there's about 80% overlap in members on those lists, inflating the number of MailChimp subscribers, and also defeating the oft recommended concept of having only one list for a business.

ghost commented 8 years ago

Oh, a point of clarification: "Free Subscriber," "One Week Pass," "Premium Monthly Subscriber," "Premium Full Year Pass," "Administrator," and "pending" are s2/WordPress member labels. "newsletter" and "raffle" are not, nor are they CCAP labels. They are completely independent of the membership site, but otherwise related to the business.

jaswrks commented 8 years ago

@bobeaston Thanks for the feature request :-)

If I understand correctly, the issue is that there are Interest Groups that s2Member is unaware of, and so whenever a transition occurs, the Interest Groups that s2Member is unaware of are being removed in favor of only those which are listed in your MailChimp configuration for s2Member. Is that about right?

The MailChimp API has a replace_interests flag that we default to a value of true in s2Member, so that Interest Groups are updated to reflect the configured values that you gave to s2Member for a given Membership Level.

I take it that you cannot just give s2Member the additional Interest Groups in your configuration due to those being managed elsewhere. Do I have that right?

I suppose a possible short-term solution would be to filter this setting in s2Member. I'm not entirely sure that will resolve the problem for you though. See: this line of code.

To filter that setting off, create this directory and file:

/wp-content/mu-plugins/s2-hacks.php

<?php
add_filter('ws_plugin__s2member_mailchimp_replace_interests', '__return_false');
ghost commented 8 years ago

Yes Jason, you understand the problem correctly. The "Acnathus Book" group values are being cleared whenever s2Member updates that list members s2Member values.

I'll try your suggestion and let you know.

THANKS!

ghost commented 8 years ago

Unfortunately... it still fails. I too thought that was the parameter causing problems and even modified s2Member code before you suggested the filter. No joy!

However, don't lose any sleep over it. I think this is about my "last straw" with MailChinp. Don't get me wrong; it's not you. It's them. I find almost all of their processes rich with cuteness while being incredibly obtuse. Maybe one of their chimps wrote the documentation? :) I'm ready to switch to ConvertKit, even if it means writing my own hooks to s2Member.

Thanks for taking a look and for the suggestion.

jaswrks commented 8 years ago

Ah, bummer. Thanks for the follow-up! :-) I'll leave this issue open and perhaps we can take a closer look and try to improve upon this at some point in the near future.

ghost commented 8 years ago

THANKS Jason!

On Tue, Oct 27, 2015 at 1:48 AM, JasWSInc notifications@github.com wrote:

Ah, bummer. Thanks for the follow-up! :-) I'll leave this issue open and perhaps we can take a closer look and try to improve upon this at some point in the near future.

— Reply to this email directly or view it on GitHub https://github.com/websharks/s2member/issues/757#issuecomment-151382256.

ghost commented 8 years ago

Just an update: I've been retracing previous steps to double check...

Test method: s2member is configured to update an interest_group field on a particular list as members transition between levels. This works exactly as expected. At MailChimp I have an ADDITIONAL interest group for all list members, which I want to manage independently of the interest group s2member manages. To test: (1) At MailChimp I manually set values in that additional group for a particular member. (2) I use the WordPress Users panel to change the member level for that member. (3) Back to MailChimp to check the result .... which always is updating the member level correctly, but erasing the values in the other interest group.

First, an explanation from a person at MailChimp support: "Setting update_existing: true and replace_interests: false will accomplish what you want - just passing new group choices (not having to include previous ones), and having them added to existing group choices. It's also good to note here that if you don't include the replace_interests property, it will default to true and may explain what you were seeing when using update_existing: true."

I re-tried the MU filter suggested above - same failure.

On grepping all of s2member, I found 4 files that affect "replace_interests". I changed true to false in all of them as follows: (filename - line number(s) - change) * \includes\classes\mailchimp.inc.php - 113 - changed TRUE to FALSE * \includes\classes\mailchimp-o.inc.php - 111 - changed TRUE to FALSE * \includes\externals\mailchimp\Mailchimp\Lists.php - 73, 741, 780 - changed true to false * \includes\externals\mailchimp\Mailchimp-o.php - 1580, 1631, 1665 - changed true to false Results: same failure

Next, I'll inspect for possible "default to true" cases.

ghost commented 8 years ago

Yet another test ... conducted exactly as above, with all of those "false" values still in place.

I turned on logging for the duration of this single transaction. I changed the user known as "s2free" from "Free Member" to "One Week Pass" and then collected the mailchimp.api log file.

The only mention of "replace_interests" in the log file is in what I believe is the return results from MailChimp, which shows no value for api_replace_interests.
See line 471: [api_replace_interests] => Does the absence of a value there indicate not specified, which defaults to true?

Log file: ---- Log file BEGIN ---- LOG ENTRY: Sun Nov 15th, 2015 @ precisely 1:02 pm UTC PHP v5.4.42 :: WordPress v4.3.1 :: s2Member v150925 :: s2Member Pro v150925 Memory 47.87 MB :: Real Memory 48.50 MB :: Peak Memory 47.99 MB :: Real Peak Memory 48.50 MB www.marymaycarving.com/carvingschool/wp-admin/user-edit.php User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36 Array ( [args] => stdClass Object ( [role] => subscriber [level] => 0 [ccaps] => [login] => s2free [pass] => [email] => s2free@eastonstudio.com [fname] => free [lname] => loader [ip] => [opt_out] => 1 [opt_in] => [double_opt_in] => [user] => WP_User Object ( [data] => stdClass Object ( [ID] => 3667 [user_login] => s2free [user_pass] => $P$BBXKEan4fD74YJUMs8mGk.CY16D1vM. [user_nicename] => s2free [user_email] => s2free@eastonstudio.com [user_url] => [user_registered] => 2015-08-29 19:39:42 [user_activation_key] => 1446254537:$P$BFtZ9ewN1VrQSkeglKQ4ZX8OtuAjY21 [user_status] => 0 [display_name] => free loader )

                [ID] => 3667
                [caps] => Array
                    (
                        [subscriber] => 1
                    )

                [cap_key] => wp_capabilities
                [roles] => Array
                    (
                        [0] => subscriber
                    )

                [allcaps] => Array
                    (
                        [read] => 1
                        [level_0] => 1
                        [access_s2member_level0] => 1
                        [subscriber] => 1
                    )

                [filter] => 
            )

        [user_id] => 3667
        [name] => free loader
    )

[function] => unsubscribe
[list] => 4545aa279b::Member level::Free Subscriber
[list_id] => 4545aa279b
[api_method] => listUnsubscribe
[api_properties] => Mailchimp Object
    (
        [apikey] => 0033517142e758fbe5f441982bd67b2c-us8
        [ch] => Resource id #843
        [root] => https://us8.api.mailchimp.com/2.0/
        [debug] => 
        [folders] => Mailchimp_Folders Object
            (
                [master] => Mailchimp Object

RECURSION )

        [templates] => Mailchimp_Templates Object
            (
                [master] => Mailchimp Object

RECURSION )

        [users] => Mailchimp_Users Object
            (
                [master] => Mailchimp Object

RECURSION )

        [helper] => Mailchimp_Helper Object
            (
                [master] => Mailchimp Object

RECURSION )

        [mobile] => Mailchimp_Mobile Object
            (
                [master] => Mailchimp Object

RECURSION )

        [conversations] => Mailchimp_Conversations Object
            (
                [master] => Mailchimp Object

RECURSION )

        [ecomm] => Mailchimp_Ecomm Object
            (
                [master] => Mailchimp Object

RECURSION )

        [neapolitan] => Mailchimp_Neapolitan Object
            (
                [master] => Mailchimp Object

RECURSION )

        [lists] => Mailchimp_Lists Object
            (
                [master] => Mailchimp Object

RECURSION )

        [campaigns] => Mailchimp_Campaigns Object
            (
                [master] => Mailchimp Object

RECURSION )

        [vip] => Mailchimp_Vip Object
            (
                [master] => Mailchimp Object

RECURSION )

        [reports] => Mailchimp_Reports Object
            (
                [master] => Mailchimp Object

RECURSION )

        [gallery] => Mailchimp_Gallery Object
            (
                [master] => Mailchimp Object

RECURSION )

        [goal] => Mailchimp_Goal Object
            (
                [master] => Mailchimp Object

RECURSION )

    )

[interest_groups] => Array
    (
        [GROUPINGS] => Array
            (
                [0] => Array
                    (
                        [name] => Member level
                        [groups] => Array
                            (
                                [0] => Free Subscriber
                            )

                    )

            )

    )

[interest_groups_title] => Member level
[api_delete_member] => 
[api_send_goodbye] => 
[api_send_notify] => 
[api_response] => Array
    (
        [complete] => 1
    )

[api_success] => 1

)

LOG ENTRY: Sun Nov 15th, 2015 @ precisely 1:02 pm UTC PHP v5.4.42 :: WordPress v4.3.1 :: s2Member v150925 :: s2Member Pro v150925 Memory 48.09 MB :: Real Memory 48.75 MB :: Peak Memory 48.21 MB :: Real Peak Memory 48.75 MB www.marymaycarving.com/carvingschool/wp-admin/user-edit.php User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36 Array ( [args] => stdClass Object ( [role] => s2member_level1 [level] => 1 [ccaps] => [login] => s2free [pass] => [email] => s2free@eastonstudio.com [fname] => free [lname] => loader [ip] => [opt_out] => [opt_in] => 1 [double_opt_in] => [user] => WP_User Object ( [data] => stdClass Object ( [ID] => 3667 [user_login] => s2free [user_pass] => $P$BBXKEan4fD74YJUMs8mGk.CY16D1vM. [user_nicename] => s2free [user_email] => s2free@eastonstudio.com [user_url] => [user_registered] => 2015-08-29 19:39:42 [user_activation_key] => 1446254537:$P$BFtZ9ewN1VrQSkeglKQ4ZX8OtuAjY21 [user_status] => 0 [display_name] => free loader )

                [ID] => 3667
                [caps] => Array
                    (
                        [subscriber] => 1
                    )

                [cap_key] => wp_capabilities
                [roles] => Array
                    (
                        [0] => subscriber
                    )

                [allcaps] => Array
                    (
                        [read] => 1
                        [level_0] => 1
                        [access_s2member_level0] => 1
                        [subscriber] => 1
                    )

                [filter] => 
            )

        [user_id] => 3667
        [name] => free loader
    )

[function] => subscribe
[list] => 4545aa279b::Member level::One Week Pass
[list_id] => 4545aa279b
[api_method] => listSubscribe
[api_properties] => Mailchimp Object
    (
        [apikey] => 0033517142e758fbe5f441982bd67b2c-us8
        [ch] => Resource id #853
        [root] => https://us8.api.mailchimp.com/2.0/
        [debug] => 
        [folders] => Mailchimp_Folders Object
            (
                [master] => Mailchimp Object

RECURSION )

        [templates] => Mailchimp_Templates Object
            (
                [master] => Mailchimp Object

RECURSION )

        [users] => Mailchimp_Users Object
            (
                [master] => Mailchimp Object

RECURSION )

        [helper] => Mailchimp_Helper Object
            (
                [master] => Mailchimp Object

RECURSION )

        [mobile] => Mailchimp_Mobile Object
            (
                [master] => Mailchimp Object

RECURSION )

        [conversations] => Mailchimp_Conversations Object
            (
                [master] => Mailchimp Object

RECURSION )

        [ecomm] => Mailchimp_Ecomm Object
            (
                [master] => Mailchimp Object

RECURSION )

        [neapolitan] => Mailchimp_Neapolitan Object
            (
                [master] => Mailchimp Object

RECURSION )

        [lists] => Mailchimp_Lists Object
            (
                [master] => Mailchimp Object

RECURSION )

        [campaigns] => Mailchimp_Campaigns Object
            (
                [master] => Mailchimp Object

RECURSION )

        [vip] => Mailchimp_Vip Object
            (
                [master] => Mailchimp Object

RECURSION )

        [reports] => Mailchimp_Reports Object
            (
                [master] => Mailchimp Object

RECURSION )

        [gallery] => Mailchimp_Gallery Object
            (
                [master] => Mailchimp Object

RECURSION )

        [goal] => Mailchimp_Goal Object
            (
                [master] => Mailchimp Object

RECURSION )

    )

[interest_groups] => Array
    (
        [GROUPINGS] => Array
            (
                [0] => Array
                    (
                        [name] => Member level
                        [groups] => Array
                            (
                                [0] => One Week Pass
                            )

                    )

            )

    )

[interest_groups_title] => Member level
[merge_array] => Array
    (
        [MERGE1] => free
        [MERGE2] => loader
        [OPTIN_IP] => 
        [OPTIN_TIME] => 2015-11-15 13:02:04
        [GROUPINGS] => Array
            (
                [0] => Array
                    (
                        [name] => Member level
                        [groups] => Array
                            (
                                [0] => One Week Pass
                            )

                    )

            )

    )

[api_merge_array] => Array
    (
        [MERGE1] => free
        [MERGE2] => loader
        [OPTIN_IP] => 
        [OPTIN_TIME] => 2015-11-15 13:02:04
        [GROUPINGS] => Array
            (
                [0] => Array
                    (
                        [name] => Member level
                        [groups] => Array
                            (
                                [0] => One Week Pass
                            )

                    )

            )

    )

[api_email_type] => html
[api_double_optin] => 
[api_update_existing] => 1
[api_replace_interests] => 
[api_send_welcome] => 
[api_response] => Array
    (
        [email] => s2free@eastonstudio.com
        [euid] => 184c486410
        [leid] => 248099909
    )

[api_success] => 1

)

---- Log file END ----

ghost commented 8 years ago

OK. Now, I see what is happening. It has NOTHING to do with the "replace_interests" setting.

When a member transitions between membership levels, s2member handles the MailChimp change in two steps: (1) It UNSUBSCRIBES the member. This is where the interest groups get wiped out. (2) It SUBSCRIBES again with the interest group that s2member knows about.

The UNSUBSCRIBE is the root of this problem. I understand why s2member did it that way, and I also understand that transforming these two transactions into one update transaction is not trivial.

Now that I understand why/how it is happening, I'll come up with another strategy for dealing with the additional interest group information I wanted to keep on the same list. It actually means maintaining a separate list for that information, and additional cost at MailChimp.

jaswrks commented 8 years ago

(1) It UNSUBSCRIBES the member. This is where the interest groups get wiped out.

Ah, that makes sense. Thanks for pointing that out!