Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable Mailchimp double opt-in [closed]

I'm using Ruby on Rails and I would like to disable the double opt-it but have NFI how to do it.

How do I send the variable to the API?

Thank you

like image 797
taffetto Avatar asked Oct 31 '22 21:10

taffetto


1 Answers

Here's a subscribe method you might use in a model for adding a user to a MailChimp mailing list:

  def subscribe
    mailchimp = Gibbon::API.new(Rails.application.secrets.mailchimp_api_key)
    result = mailchimp.lists.subscribe({
      :id => Rails.application.secrets.mailchimp_list_id,
      :email => {:email => self.email},
      :double_optin => false,
      :update_existing => true,
      :send_welcome => true
    })
    Rails.logger.info("Subscribed #{self.email} to MailChimp") if result
  end

It uses the Gibbon gem. One of the key/value pairs in the hash is :double_optin => false.

The example is from my book, Learn Ruby on Rails, which includes a chapter showing how to build an application that allows a user to subscribe to a mailing list.

like image 148
Daniel Kehoe Avatar answered Nov 15 '22 07:11

Daniel Kehoe