You are here

function campaignmonitor_user_form in Campaign Monitor 5.2

Same name and namespace in other branches
  1. 5 campaignmonitor.module \campaignmonitor_user_form()
  2. 6 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 228

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', '');
  $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_userpagedisplaytext', 'Newsletter'),
    '#default_value' => $default,
  );
  $form['is_subscribed'] = array(
    '#type' => 'hidden',
    '#default_value' => $default,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  return $form;
}