--- ucreate.module 2008-10-29 11:51:06.000000000 -0400 +++ ucreate.module 2009-03-11 08:47:32.000000000 -0400 @@ -263,29 +263,20 @@ function ucreate_user_create($edit) { $edit['pass'] = $password; $edit['status'] = 1; $account = user_save($account, $edit); - // Notify user if successful. if ($account->uid) { drupal_set_message(t('You have created an account for !name, password and login instructions have been sent to the e-mail address !email.', array('!name' => $edit['name'], '!email' => l($edit['mail'], 'mailto:'. $edit['mail'])))); - $subject = t('[!site_name] We have created an account for you', array('!site_name' => variable_get('site_name', 'Drupal'))); - $variables = array( + //$subject = t('[!site_name] We have created an account for you', array('!site_name' => variable_get('site_name', 'Drupal'))); + $params = array( '!name' => $edit['name'], '!site' => variable_get('site_name', 'Drupal'), '!login_url' => user_pass_reset_url($account) .'/login', - '!url' => trim(url(array('absolute' => TRUE)), '/'), + '!url' => trim(url('/', array('absolute' => TRUE))), '!password' => $password, + 'welcome_message' => $edit['welcome_message_body'], ); - if (trim($edit['welcome_message_body'])) { - $body .= $edit['welcome_message_body']; - $body .= "\n\n================================================\n"; - } - else { - $body .= t("\nHello !name,\n", $variables); - } - // @todo: Would love to use one time login link here - alas it is only valid for 24 hrs and needs to be renewed then. - $body .= t("\nWe have created an account for you on !site\n!url.\n\nYou can log in to the site with the following username and password\n\n!name\n!password\n\nPlease change your password after the first time you log in.\n\nWelcome to !site", $variables); - if (!drupal_mail('ucreate-create', $edit['mail'], $subject, $body)) { + if (!drupal_mail('ucreate', 'create', $account->mail, user_preferred_language($account), $params)) { drupal_set_message(t('Error sending notification mail to user.'), 'error'); } } @@ -294,3 +285,23 @@ function ucreate_user_create($edit) { } return $account; } + +function ucreate_mail($key, &$message, $params) { + $language = $message['language']; + $variables = user_mail_tokens($params['account'], $language); + switch($key) { + case 'create': + $message['subject'] = t('[!site_name] We have created an account for you', array('!site_name' => variable_get('site_name', 'Drupal'))); + $message['body'] = ''; + if (trim($params['welcome_message'])) { + $message['body'] .= $params['welcome_message']; + $message['body'] .= "\n\n================================================\n"; + } + else { + $message['body'] .= t("\nHello !name,\n", $params); + } + // @todo: Would love to use one time login link here - alas it is only valid for 24 hrs and needs to be renewed then. + $message['body'] .= t("\nWe have created an account for you on !site\n!url.\n\nYou can log in to the site with the following username and password\n\nUsername: !name\nPassword: !password\n\nPlease change your password after the first time you log in.\n\nWelcome to !site", $params); + break; + } +}