Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Option to Subscribe to Blog via MailChimp List #114

Closed
raamdev opened this issue Jun 26, 2015 · 45 comments
Closed

Feature Request: Option to Subscribe to Blog via MailChimp List #114

raamdev opened this issue Jun 26, 2015 · 45 comments
Assignees
Milestone

Comments

@raamdev
Copy link
Contributor

raamdev commented Jun 26, 2015

It would be GREAT if Comment Mail included an option to allow a commenter to optionally subscribe to the blog via a specific MailChimp list at the same time that they leave a comment.

For example, the Jetpack Subscriptions module allows for this (except it uses WordPress.com to manage the subscriptions, not a MailChimp list):

2015-06-26_10-59-34


Feature Wishlist

I'd love to see the following features related to this:

  • Custom Label / Description: The Jetpack feature doesn't allow you to easily change the "Follow this blog" text; it would be nice if a site owner could customize the text for this option that shows up on the comment form.
  • Merge Fields w/ Replacement Codes: One thing I do on my personal site is segment my mailing list based on the topic the subscriber is interested in hearing more about, so, for example, I have a "Topic" group that is based on the category of the Post and if someone subscribes to the blog while reading a post in the "Technology" category, the Topic field on MailChimp gets assigned "Technology". Even if there isn't a whole lot in terms of UI here, it would be nice to be able to configure the MailChimp integration however we want, even if that means editing some templates with PHP. This would also make it possible for a site owner to pass additional fields to MailChimp on a site where users are required to be logged in (i.e., each commenter already has other meta data associated with their account that a site owner wants to include when creating a subscription on MailChimp).

Forked from #113 (comment).

@jaswrks
Copy link

jaswrks commented Aug 4, 2015

Referencing an existing integration with the MailChimp API that was done in s2Member:
https://github.com/websharks/s2member/blob/000000-dev/s2member/includes/classes/mailchimp.inc.php

It uses the MailChimp PHP SDK for v2 of the MailChimp API:
https://bitbucket.org/mailchimp/mailchimp-api-php/src

@raamdev
Copy link
Contributor Author

raamdev commented Aug 4, 2015

Added a Feature Wishlist above. ↑

@jaswrks
Copy link

jaswrks commented Aug 4, 2015

@kristineds I'm assigning this to you, and I'll try to work with you a little bit at a time in order to make some progress on this. I'm going break this down into small phases and explain what needs to happen along the way--as time allows. I'll start with the MailChimp API and explain that we need to add a new submodule to the pro repo as a way to prepare for work that needs to occur in the near future.


This is something that you can go ahead and get started on now if you like :-)

Adding the Submodule (Next Steps)

Note: MailChimp integration will be available in the pro version only at this time.

Start Feature Branch

$ cd ~/projects/websharks/comment-mail-pro
$ git checkout 000000-dev # Start from the dev branch.
$ git pull # Make sure you're working from an up-to-date copy w/ all of the latest changes.
$ git checkout -b feature/114 # A new feature branch for this issue.

Update Submodules

$ cd ~/projects/websharks/comment-mail-pro
$ git submodule init # Initialize submodules, just in case you haven't done this already. If you've already done it, doing it again won't hurt anything.
$ git submodule update # Make sure all Git submodules are up-to-date.

Add New Submodule

$ cd ~/projects/websharks/comment-mail-pro
$ git submodule add https://bitbucket.org/mailchimp/mailchimp-api-php comment-mail-pro/submodules/mailchimp

Note: This brings the MailChimp PHP SDK into the Comment Mail source code as a Git submodule. This way it will be available to us as part of the Comment Mail distribution whenever we work on the next steps; i.e., whenever we implement calls to the MailChimp API.


Commit and Push Changes

$ cd ~/projects/websharks/comment-mail-pro
$ git status # Quick review. You should be on the feature/114 branch.
$ git add --all && git commit -m 'Adding MailChimp submodule; see websharks/comment-mail#114'
$ git push -u origin feature/114

Submit a Pull Request

Pro version only, please submit a pull request.

@kristineds
Copy link
Contributor

@jaswsinc Submitting Comment Mail Pro PR for Adding MailChimp submodule: #114

jaswrks pushed a commit to wpsharks/comment-mail-pro that referenced this issue Aug 5, 2015
@raamdev
Copy link
Contributor Author

raamdev commented Aug 5, 2015

@jaswsinc I assume this should not have been closed?

@raamdev
Copy link
Contributor Author

raamdev commented Aug 5, 2015

@kristineds Keep in mind when submitting Pull Requests that if a particular PR doesn't actually close a GitHub Issue, i.e., it's just part of working towards closing a GitHub issue, then you don't want to use the word "Closes" inside the body of the Pull Request, otherwise when the PR gets merged, the associated GitHub issue will be automatically closed by GitHub. In this case, it would have been better to just write See websharks/comment-mail#114 inside the PR body. :-)

No worries, just something to keep in mind for future reference.

I personally prefer to never use "Closes" in a GitHub Pull Request and instead manually close the associated GitHub issue when I know it's ready to be closed. That's better than accidentally closing it and forgetting that there was more work to be done on that issue.

@jaswrks
Copy link

jaswrks commented Aug 5, 2015

I assume this should not have been closed?

@raamdev Correct. Thanks for catching that.

@jaswrks jaswrks reopened this Aug 5, 2015
@kristineds
Copy link
Contributor

In this case, it would have been better to just write See #114 inside the PR body.

@raamdev Noted. That makes sense. Didn't know that. :)

@jaswrks
Copy link

jaswrks commented Aug 11, 2015

Next Actions (Step 2)

New Feature Branch

feature/114-step2 (pro version only)

Add Abstract Base Class for List Server Integrations

comment-mail-pro/includes/class/list-server-base.php
See also: http://php.net/manual/en/language.oop5.abstract.php

<?php
/**
 * List Server Abstraction
 *
 * @since 15xxxx Adding support for mailing lists.
 * @copyright WebSharks, Inc. <http://www.websharks-inc.com>
 * @license GNU General Public License, version 3
 */
namespace comment_mail // Root namespace.
{
    if(!defined('WPINC')) // MUST have WordPress.
        exit('Do NOT access this file directly: '.basename(__FILE__));
    if(!class_exists('\\'.__NAMESPACE__.'\\list_server_base'))
    {
        /**
         * List Server Abstraction
         *
         * @since 15xxxx Adding support for mailing lists.
         */
        abstract class list_server_base extends abs_base
        {
            /**
             * Subscribe to list.
             *
             * @since 15xxxx Adding support for mailing lists.
             *
             * @param array $list An array with details that identify a particular list.
             * @param array $args User ID, email address, IP, etc. Details needed by the list server.
             *
             * @return string Subscriber ID. If already exists on the list, the existing ID.
             */
            abstract public function subscribe(array $list, array $args);

            /**
             * Unsubscribe from list.
             *
             * @since 15xxxx Adding support for mailing lists.
             *
             * @param array $list An array with details that identify a particular list.
             * @param array $args User ID, email address, IP, etc. Details needed by the list server.
             *
             * @return boolean True if removed from the list. True if not on the list. False on failure.
             */
            abstract public function unsubscribe(array $list, array $args);
        }
    }
}

MailChimp Class (Extends Base)

comment-mail-pro/includes/classes/list-server-mailchimp.php
See also: http://php.net/manual/en/language.oop5.inheritance.php

<?php
/**
 * MailChimp List Server
 *
 * @since 15xxxx Adding support for mailing lists.
 * @copyright WebSharks, Inc. <http://www.websharks-inc.com>
 * @license GNU General Public License, version 3
 */
namespace comment_mail // Root namespace.
{
    if(!defined('WPINC')) // MUST have WordPress.
        exit('Do NOT access this file directly: '.basename(__FILE__));
    if(!class_exists('\\'.__NAMESPACE__.'\\list_server_mailchimp'))
    {
        /**
         * MailChimp List Server
         *
         * @since 15xxxx Adding support for mailing lists.
         */
        class list_server_mailchimp extends list_server_base
        {
            /**
             * Subscribe to list.
             *
             * @since 15xxxx Adding support for mailing lists.
             *
             * @param array $list An array with details that identify a particular list.
             * @param array $args User ID, email address, IP, etc. Details needed by the list server.
             *
             * @return string Subscriber ID. If already exists on the list, the existing ID.
             */
            public function subscribe(array $list, array $args)
            {
                // Integration with MailChimp API.
            }

            /**
             * Unsubscribe from list.
             *
             * @since 15xxxx Adding support for mailing lists.
             *
             * @param array $list An array with details that identify a particular list.
             * @param array $args User ID, email address, IP, etc. Details needed by the list server.
             *
             * @return boolean True if removed from the list. True if not on the list. False on failure.
             */
            public function unsubscribe(array $list, array $args)
            {
                // Integration with MailChimp API.
            }
        }
    }
}

Submit Pull Request

@jaswrks
Copy link

jaswrks commented Aug 11, 2015

Next Actions (Step 3)

New Feature Branch

feature/114-step3 (pro and lite versions)

MailChimp Config. Option Keys

Pro Version

After this line add a new section:

# Related to list server integrations.

'list_server_enable'  => '0', // `0|1`; enable?
'list_server' => 'mailchimp', // List server identifier.

'list_server_mailchimp_api_key' => '', // MailChimp API key.
'list_server_mailchimp_list_id' => '', // MailChimp list ID.

Lite Version (Awareness)

After this line in the lite version, we need to make Comment Mail aware that this functionality will be possible once you upgrade. These keys help with our Pro Preview functionality.

Add the following keys after this line:

# Related to list server integrations.

'list_server_enable',
'list_server',

'list_server_mailchimp_api_key',
'list_server_mailchimp_list_id',

Submit Pull Request

@jaswrks
Copy link

jaswrks commented Aug 11, 2015

Next Actions (Step 4)

New Feature Branch

feature/114-step4 (pro version only)

List Server Utilities Class

comment-mail-pro/includes/classes/utils-list-server.php

<?php
/**
 * List Server Utilities
 *
 * @since 15xxxx Adding list server integrations.
 * @copyright WebSharks, Inc. <http://www.websharks-inc.com>
 * @license GNU General Public License, version 3
 */
namespace comment_mail // Root namespace.
{
    if(!defined('WPINC')) // MUST have WordPress.
        exit('Do NOT access this file directly: '.basename(__FILE__));
    if(!class_exists('\\'.__NAMESPACE__.'\\utils_list_server'))
    {
        /**
         * List Server Utilities
         *
         * @since 15xxxx Adding list server integrations.
         */
        class utils_list_server extends abs_base
        {
            // @TODO Process subscribe and unsubscribe actions.
        }
    }
}

Property Annotation for IDEs

After this line add a new line for these utilities.

* @property-read utils_list_server $utils_list_server

Submit Pull Request

@jaswrks
Copy link

jaswrks commented Aug 11, 2015

What's on deck after these?

  • Write code that interacts with MailChimp in this class:
    comment-mail-pro/includes/classes/list-server-mailchimp.php
  • Write code that handles subscribe/unsubscribe actions based on Comment Mail configuration in this class: comment-mail-pro/includes/classes/utils-list-server.php

@raamdev raamdev assigned jaswrks and unassigned renzms Nov 6, 2016
jaswrks pushed a commit to wpsharks/comment-mail-pro that referenced this issue Nov 7, 2016
@jaswrks
Copy link

jaswrks commented Nov 7, 2016

@raamdev @renzms Fixed in the dev branch by wpsharks/comment-mail-pro@d47f012

@renzms Thanks for catching that! 💯

@jaswrks
Copy link

jaswrks commented Nov 7, 2016

Next Release Changelog:

  • New Feature: Adding support for MailChimp integration. Requires pro version. It is now possible to give users the option of subscribing to your site-wide mailing list whenever they leave a comment or reply; i.e., in addition to subscribing to comment reply notifications they can also join your MailChimp mailing list. See also: issue #114 for further details.

@raamdev
Copy link
Contributor Author

raamdev commented Nov 7, 2016

@renzms Can you fetch the dev branch updates, rebuild, and confirm Jason's fix when you get a chance.

@renzms
Copy link
Contributor

renzms commented Nov 8, 2016

@raamdev @jaswsinc

Tested the latest dev branch.

I can confirm there is no longer a PHP error. 👍


I noticed this behavior though with the Subscription/Auto-Confirm Workflow in the following conditions, please let me know if this is the correct/expected behavior:

Steps to Reproduce

  • Setup MailChimp integration and Lists
  • Enable Auto-Confirm in dropdown , Yes, automatically auto-confirm everyone; i.e., never ask for email confirmation
  • Test and comment to auto-subscribe and receive the auto-confirmation email.

Scenario 1: Unsubscribed Users cannot resubscribe:

  • Click unsubscribe from the auto-confirmation email
  • Test and comment again with Auto-Confirm still enabled
  • Comment appears right away with no error prompt
  • No confirmation email is sent for "re-subscription" and MailChimp list will no longer add user/re-subscribe user who previously unsubscribed to the same list integrated with Comment Mail
  • No admin confirmation email is sent that a user has tried to subscribe and/or checked the subscription box. MailChimp Dashboard will no longer allow admin to add user/re-subscribe user who previously unsubscribed to the same List that was integrated with Comment Mail

Scenario 2: Admin can change integrated MailChimp List ID to circumvent cancelling subscriptions:

  • As admin, change integrated MailChimp List ID in Comment Mail settings to new List
  • Subscriber will be sent auto-confirmation email again when commenting and be subscribed to new list
  • As commenter Unsubscribe again from list and comment as normal
  • Admin can then change List ID in Comment Mail settings to new List again to circumvent MailChimp blocking users from re-subscribing/unsubscribing from same List ID
  • When commenting again with Auto-Confirm still enabled, Subscriber will be sent auto-confirmation email again

jaswrks pushed a commit to wpsharks/comment-mail-pro that referenced this issue Nov 8, 2016
@jaswrks
Copy link

jaswrks commented Nov 8, 2016

No confirmation email is sent for "re-subscription" and MailChimp list will no longer add user/re-subscribe user who previously unsubscribed to the same list integrated with Comment Mail

@renzms Thank you for catching this. I updated the dev branch again with a workaround for this. If you can test again I'd really appreciate it. What should happen if you unsubscribe and then try again, is that on your attempt to resubscribe you should get a confirmation request via email.

i.e., Once you unsubscribe, MailChimp requires a double opt-in via email confirmation on your next attempt to subscribe. Not ideal, but that's the best I've been able to do for now.

@jaswrks
Copy link

jaswrks commented Nov 9, 2016

@renzms writes...

@jaswsinc I spent some time testing the recent fix for this: #114 (comment), but I still got the same result and was not receiving any re-subscription email after unsubscribing once while Auto-Confirm is enabled. I removed Data Safeguards, updated git submodules and double-checked I had the latest dev branch.

@jaswsinc writes...

@renzms Thank you! I will go back and do some testing on this and see if I can get it fixed up better-er. Sorry for wasting your time thus far. I thought I had this working.

@raamdev raamdev removed the in review label Nov 9, 2016
@jaswrks
Copy link

jaswrks commented Nov 9, 2016

Referencing debug output from tests of my own to reproduce the issue reported by Renz.

[xdebug_message] => 
Mailchimp_List_InvalidUnsubMember: xxxx@xxxxx.com has unsubscribed, and cannot be resubscribed by you. To prevent false spam complaints, they'll need to resubscribe of their own free will. in /wp-business/plugins/comment-mail-pro/src/vendor/mailchimp/mailchimp/src/Mailchimp.php on line 253

Call Stack:
    0.0011     368280   1. {main}() /app/src/index.php:0
    0.0019     368568   2. require('/app/src/wp-blog-header.php') /app/src/index.php:17
    0.0023     368920   3. require_once('/app/src/wp-load.php') /app/src/wp-blog-header.php:13
    0.0030     369704   4. require_once('/app/src/wp-config.php') /app/src/wp-load.php:39
    0.0037     371576   5. require_once('/app/src/wp-settings.php') /app/src/wp-config.php:42
    0.1287    2498632   6. do_action() /app/src/wp-settings.php:411
    0.1287    2499032   7. WebSharks\CommentMail\Pro\Plugin->actions() /app/src/wp-includes/plugin.php:524
    0.1296    2500840   8. WebSharks\CommentMail\Pro\Actions->__construct() /wp-business/plugins/comment-mail-pro/src/includes/classes/Plugin.php:1034
    0.1320    2507000   9. WebSharks\CommentMail\Pro\Actions->maybeDoSubActions() /wp-business/plugins/comment-mail-pro/src/includes/classes/Actions.php:39
    0.1334    2508856  10. WebSharks\CommentMail\Pro\SubActions->__construct() /wp-business/plugins/comment-mail-pro/src/includes/classes/Actions.php:75
    0.1334    2508920  11. WebSharks\CommentMail\Pro\SubActions->maybeHandle() /wp-business/plugins/comment-mail-pro/src/includes/classes/SubActions.php:42
    0.1335    2508968  12. WebSharks\CommentMail\Pro\SubActions->confirm() /wp-business/plugins/comment-mail-pro/src/includes/classes/SubActions.php:63
    0.1396    2533360  13. WebSharks\CommentMail\Pro\UtilsSub->confirm() /wp-business/plugins/comment-mail-pro/src/includes/classes/SubActions.php:104
    0.1417    2609024  14. WebSharks\CommentMail\Pro\SubUpdater->__construct() /wp-business/plugins/comment-mail-pro/src/includes/classes/UtilsSub.php:280
    0.1417    2609024  15. WebSharks\CommentMail\Pro\SubInserter->__construct() /wp-business/plugins/comment-mail-pro/src/includes/classes/SubUpdater.php:33
    0.1427    2658400  16. WebSharks\CommentMail\Pro\SubInserter->maybeInsertUpdate() /wp-business/plugins/comment-mail-pro/src/includes/classes/SubInserter.php:479
    0.1441    2661176  17. WebSharks\CommentMail\Pro\SubInserter->update() /wp-business/plugins/comment-mail-pro/src/includes/classes/SubInserter.php:697
    0.1561    2732200  18. WebSharks\CommentMail\Pro\UtilsListServer->maybeSubscribe() /wp-business/plugins/comment-mail-pro/src/includes/classes/SubInserter.php:861
    1.0419    3086600  19. WebSharks\CommentMail\Pro\ListServerMailchimp->subscribe() /wp-business/plugins/comment-mail-pro/src/includes/classes/UtilsListServer.php:46
    1.0420    3097360  20. call_user_func_array:{/wp-business/plugins/comment-mail-pro/src/includes/classes/ListServerMailchimp.php:66}() /wp-business/plugins/comment-mail-pro/src/includes/classes/ListServerMailchimp.php:66
    1.0420    3097864  21. Mailchimp_Lists->subscribe() /wp-business/plugins/comment-mail-pro/src/includes/classes/ListServerMailchimp.php:66
    1.0420    3098240  22. Mailchimp->call() /wp-business/plugins/comment-mail-pro/src/vendor/mailchimp/mailchimp/src/Mailchimp/Lists.php:744

@jaswrks
Copy link

jaswrks commented Nov 9, 2016

Noting that "double_optin":true or false makes no difference.

jaswrks pushed a commit to wpsharks/comment-mail-pro that referenced this issue Nov 9, 2016
@jaswrks
Copy link

jaswrks commented Nov 9, 2016

@renzms @raamdev I have been unable to find a way around this problem given limitations in v2 of the MailChimp API that I have been working with. Once a user unsubscribes, the MailChimp API refuses to add them again no matter what settings I use in the API call.

I suggest that we release the MailChimp integration as-is (it works great otherwise) and then in the future we can take a closer look at this whenever we upgrade the MailChimp API version; i.e., we can see if there's a way to work around this in a new version of their API.

I'm opening this new issue as a fork. See: #311

@raamdev
Copy link
Contributor Author

raamdev commented Nov 9, 2016

@jaswsinc Got it. I agree with moving forward as-is. We'll upgrade the MailChimp API as part of the next release.

@raamdev
Copy link
Contributor Author

raamdev commented Nov 10, 2016

@renzms Note that I've opened a separate bug report for the issue you reported; see #312. See also Jason's notes above. We're going to proceed with releasing this feature despite the above bug, so please expect this issue to be unresolved when testing the Comment Mail RC.

@raamdev raamdev assigned renzms and unassigned jaswrks Nov 10, 2016
@renzms
Copy link
Contributor

renzms commented Nov 10, 2016

Note that I've opened a separate bug report for the issue you reported; see #312. See also Jason's notes above. We're going to proceed with releasing this feature despite the above bug, so please expect this issue to be unresolved when testing the Comment Mail RC.

Got it! Thanks!

raamdev added a commit that referenced this issue Nov 18, 2016
- **Bug Fix:** Exclude unapproved comments from the dropdown menu on the 'Subscribe Without Commenting' form. See [Issue #299](#299).
- **Enhancement:** When parsing templates, this release uses `include()` instead of `eval()` whenever possible. This improves compatibility with shared hosting providers and makes it easier to debug template parsing issues should they occur. See [Issue #192](#192).
- **PHP v7 Compatibility:** After further testing, it was found that while Comment Mail is compatible with PHP v7.0, you must be running PHP v7.0.9+. Starting with this release of Comment Mail if you're running PHP v7 < 7.0.9 a warning is displayed in the WordPress Dashboard asking the site owner to upgrade to PHP v7.0.9 or higher. Note: While PHP v7.0.9 is adequate, PHP v7.0.10 is strongly recommended. See [Issue #272](#272).
- **New SparkPost Integration** (Pro):  It is now possible to use SparkPost for Replies-via-Email (RVE) instead of Mandrill. Note that SparkPost is now the suggested RVE Handler for Comment Mail because Mandrill changed its pricing structure a while back. In short, Mandrill requires a fee, whereas SparkPost (recommended) offers Relay Webhooks as a part of their free plan. See [Issue #265](#265).
- **New Feature** (Pro): Adding support for MailChimp integration. It is now possible to give users the option of subscribing to your site-wide mailing list whenever they leave a comment or reply; i.e., in addition to subscribing to comment reply notifications they can also join your MailChimp mailing list. See [Issue #114](#114).
@raamdev
Copy link
Contributor Author

raamdev commented Nov 18, 2016

Comment Mail v161118 has been released and includes changes from this GitHub Issue. See the v161118 announcement for further details.


This issue will now be locked to further updates. If you have something to add related to this GitHub Issue, please open a new GitHub Issue and reference this one (#114).

@raamdev raamdev closed this as completed Nov 18, 2016
@wpsharks wpsharks locked and limited conversation to collaborators Nov 18, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants