You are here

function newsletter_user_insert in Newsletter 7

Implements hook_user_insert().

File

./newsletter.module, line 406
Defines menu items for newsletter administration, permissions and basic drupal hooks.

Code

function newsletter_user_insert(&$edit, $account, $category) {
  if ($lists = variable_get('newsletter_auto_subscribe_new_users', array())) {
    $subscriber = new stdClass();
    $subscriber->email = $account->mail;
    $subscriber->uid = $account->uid;
    foreach ($lists as $list) {
      $subscriber->field_newsletter_list[LANGUAGE_NONE][]['target_id'] = $list;
    }
    entity_get_controller('newsletter_subscriber')
      ->save($subscriber, variable_get('newsletter_send_confirm'));
  }
}