You are here

function campaignmonitor_user_form in Campaign Monitor 6

Same name and namespace in other branches
  1. 5.2 campaignmonitor.module \campaignmonitor_user_form()
  2. 5 campaignmonitor.module \campaignmonitor_user_form()
  3. 6.2 campaignmonitor.module \campaignmonitor_user_form()
  4. 7 modules/campaignmonitor_user/campaignmonitor_user.module \campaignmonitor_user_form()
1 string reference to 'campaignmonitor_user_form'
campaignmonitor_user_page in ./campaignmonitor.module

File

./campaignmonitor.module, line 272

Code

function campaignmonitor_user_form() {
  global $user;

  // 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);
  $email = $user->mail;
  if (_campaignmonitor_is_subscribed($api_key, $list_id, $email, true)) {
    $default = true;
  }
  else {
    $default = false;
  }
  $form['subscribe_newsletter'] = array(
    '#type' => 'checkbox',
    '#title' => variable_get('campaignmonitor_user_pagedisplaytext', 'Newsletter'),
    '#default_value' => $default,
  );
  $form['is_subscribed'] = array(
    '#type' => 'hidden',
    '#default_value' => $default,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  return $form;
}