ruby-on-railsruby-on-rails-4mailchimpgibbon

How to edit email address of existing member in mailchimp list using Gibbon gem


i've looked around for this for a long time but couldn't find any answer. In my rails 4 app i'm using the Gibbon gem (v.2.0.1) to manage mailchimp lists. Everything works fine as far as subscribing and unsunscribing users, but i cannot manage to update the email address of a subscribed user (i can change every parameter like first and last name though).

my update call looks something like:

member = $gibbon.lists(list_id).members(member_id)
member.update(body: 
              { email_address: self.email,
                status: "subscribed",
                merge_fields: {FNAME: self.first_name,
                               LNAME: self.last_name}
               }
               )

i've tried upsert as well but no luck. Is is actually possible to update emails in mailchimp or do i need to delete the user and create a new one? thanks for the help


Solution

  • After some extra research and contacting Mailchimp i can confirm that with the new api (v3.0) it is not possible to edit the email address as it is a read only field. As a solution i ran a method to specifically edit the email address, which basically retrieve the member in Mailchimp (i'm storing the mailchimp id in my db within the User model), deletes it and creates a new one with the same data (for instance, if the member is unsubscribed the new one will be unsubscribed as well). As the email address changed needs to be confirmed through an email link (i'm using Devise), i've added a resque task in the registrations controller to do execute my method. hope that helps somebody else