You are here

function _campaignmonitor_altered_form_submit in Campaign Monitor 6.3

1 string reference to '_campaignmonitor_altered_form_submit'
campaignmonitor_form_alter in ./campaignmonitor.module
Implementation of hook_form_alter().

File

./campaignmonitor.module, line 141
Module that plugs in Campaign Monitor functionality to your Drupal web site. For Campaign Monitor information see: http://www.campaignmonitor.com/

Code

function _campaignmonitor_altered_form_submit($form, &$form_state) {
  $form_values = $form_state['values'];
  $listids = $form_values['subscribe_newsletter'];
  if (count($listids) > 0) {

    // Replace api_key and list_id with your own details
    $api_key = variable_get(CM_API_KEY, '');
    foreach ($listids as $list_id) {
      if ($list_id) {
        if (_campaignmonitor_add_subscriber($api_key, $list_id, check_plain($form_values['name']), check_plain($form_values['mail']))) {

          // Only add to message if the subscriber succeeded.
          if ($form['form_id']['#value'] == 'contact_mail_page') {
            $form_values['message'] .= "\n\n" . t('You have been subscribed to newsletter(s).');
          }
        }
      }
    }
  }
}