Support » Plugin: WooCommerce MailChimp » Subscribe on email address change event

  • As far as I’ve understood the plugin subscribes users when they make purchases, but doesn’t capture their new emails if they update them under My page. Is there a way to make those updates reflect in MailChimp?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Saint Systems

    (@saintsystems)

    @hamre,

    Great question!

    You would need to add some custom code to hook into the profile_update WordPress hook (https://codex.wordpress.org/Plugin_API/Action_Reference/profile_update) and then update and/or resubscribe the user to MailChimp.

    After getting the new email address, you could update the subscription for the user like so:

    
    
        $old_email_address = 'joe@example.net';
        
        $new_email_address = 'joe@example.com';
        
        $sswcmc = SSWCMC();
        $list_id = $sswcmc->get_list();
        $subscriber_hash = $sswcmc->mailchimp()->get_subscriber_hash( $old_email_address );
        
        $resource = "lists/$list_id/members/$subscriber_hash";
        
        $args = array(
            'email_address' => $new_email_address
        );
        
        $response = $sswcmc->api->put( $resource, $args );
    
    

    [ Signature deleted ]

    • This reply was modified 9 months, 4 weeks ago by  Saint Systems.
    • This reply was modified 9 months, 4 weeks ago by  Saint Systems.
    • This reply was modified 9 months, 4 weeks ago by  Saint Systems.
    • This reply was modified 9 months, 4 weeks ago by  Saint Systems.
    • This reply was modified 9 months, 4 weeks ago by  Saint Systems.
    • This reply was modified 9 months, 4 weeks ago by  Saint Systems.
    • This reply was modified 9 months, 4 weeks ago by  Saint Systems.
    • This reply was modified 9 months, 4 weeks ago by  Saint Systems.
    • This reply was modified 2 months, 3 weeks ago by  Jan Dembowski.

    @saintsystems:

    Thank you so much for the reply and code snippet! I’ll test this out later today. I’m guessing this feature would be desired by other plugin users as well — after all, if a customer changes their email address, the expected behavior would be that they’d receive all communication from the site to their new address. Do you think it’d make sense to add this functionality to the plugin itself at some point?

    Plugin Contributor Saint Systems

    (@saintsystems)

    @hamre,

    Yes, it’s a great suggestion and we will look at adding it to the core plugin functionality.

    Thanks again and let us know if you run into any issues.

    [ Signature deleted ]

    • This reply was modified 2 months, 3 weeks ago by  Jan Dembowski.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Subscribe on email address change event’ is closed to new replies.