You are here

function campaignmonitor_general_form_submit in Campaign Monitor 6

Same name and namespace in other branches
  1. 5.2 campaignmonitor.module \campaignmonitor_general_form_submit()
  2. 5 campaignmonitor.module \campaignmonitor_general_form_submit()
  3. 6.2 campaignmonitor.module \campaignmonitor_general_form_submit()

File

./campaignmonitor.module, line 236

Code

function campaignmonitor_general_form_submit($form, &$form_state) {
  $form_values = $form_state['values'];

  // Replace api_key and list_id with your own details
  $api_key = variable_get('campaignmonitor_api_key', '');
  $list_id = variable_get('campaignmonitor_list_id', 0);
  $name = $form_values['name'];
  $email = $form_values['email'];

  // any cases other then these are when things are unchanged
  if (!$form_values['unsubscribe_newsletter']) {

    // this is the case where they now want to be subscribed, and weren't before
    _campaignmonitor_add_subscriber($api_key, $list_id, $name, $email);
  }
  else {
    if ($form_values['unsubscribe_newsletter']) {

      // this is the case where they don't want to be subscribed, and were before
      _campaignmonitor_remove_subscriber($api_key, $list_id, $email);
    }
  }
}