The Login Toboggan module improves the Drupal login system by offering the following features:
  1. Allow users to login using either their username OR their email address.
  2. Allow users to define their own password.
  3. Allow users to login immediately.
  4. Provide a login form on Access Denied pages for non-logged-in (anonymous) users.
  5. The module provides two login block options: One uses JavaScript to display the form within the block immediately upon clicking "log in". The other brings the user to a separate page, but returns the user to their original page upon login.
  6. Customize the registration form with two email fields to ensure accuracy.
These features may be turned on or off in the Login Toboggan settings.

Feel funny about people logging in at "http://yoursite.com/toboggan/login"? (Yes, we know it\'s a silly name.) You can use the path.module\'s "url aliases" to redefine Login Toboggan\'s paths as something else (perhaps: "usr/login" or just "login").

Because this module completely reorients the Drupal login process you will probably want to edit the welcome email on the user settings page. For instance if you have enabled "Set passwords during registration" you probably should not send the user\'s password out in the welcome email. Also when either "Set passwords during registration" or "Immediate login" are enabled, the %login_url becomes a verification url that the user MUST visit in order to enable authenticated status. The following is an example welcome email:

', array('%url' => url('admin/settings/logintoboggan'))); $example = t(' %username, Thank you for registering at %site. IMPORTANT: For full site access, you will need to click on this link or copy and paste it in your browser: %login_url This will verify your account and log you into the site. In the future you will be able to log in using the username and password that you created during registration. Your new %site membership also enables to you to login to other Drupal powered websites (e.g. http://www.drupal.org/) without registering. Just use the following Drupal ID along with the password you\'ve chosen: Drupal ID: %username@%uri_brief -- %site team'); $form['foo'] = array( '#type' => 'textarea', '#default_value' => $example, '#rows' => 15, ); $output = drupal_get_form('logintoboggan_help', $form); return $output; break; case 'admin/modules#description': return t('Improves Drupal\'s login system.'); break; case 'admin/settings/logintoboggan': $output = t('

Customize your login and registration system. More help can be found here.

', array('%url' => url('admin/help/logintoboggan'))); return $output; } } /** * Implementation of hook_form_alter() * * @ingroup logintoboggan_core */ function logintoboggan_form_alter($form_id, &$form) { global $form_values; switch ($form_id) { /* This will be used later when the conversion to the user login block is complete case 'block_admin_configure': if (($form['module']['#value'] == 'user') && ($form['delta']['#value'] == 0)) { $form['#submit'] += array('logintoboggan_user_block_admin_configure_submit' => array($form_id, &$form_values)); $form['block_settings'] = array( '#type' => 'fieldset', '#title' => t('Block specific settings'), '#collapsible' => true, '#weight' => 0, ); $form['block_settings']['toboggan_display_logged_in'] = array('#type' => 'checkbox', '#title' => t('Display the \'logged in\' block'), '#default_value' => variable_get('toboggan_display_logged_in', 1), ); $form['toboggan_block_type'] = array('#type' => 'radios', '#title' => t('Block type'), '#default_value' => variable_get('toboggan_block_type', 1), '#options' => array(t('Link'), t('Collapsible Form')), ); $form['block_settings']['toboggan_block_msg'] = array('#type' => 'textarea', '#title' => t('Set a custom message to appear at the top of your login block'), '#default_value' => variable_get('toboggan_block_msg', ''), ); } break;*/ case 'user_login': case 'user_login_block': if (variable_get('login_with_mail', 0)) { $form['#validate'] = array('logintoboggan_user_login_validate' => array()); $form['name']['#title'] = t('Username or Email Address'); if (count(user_auth_help_links()) > 0) { $form['name']['#description'] = t('Enter your %s username. email address, or an ID from one of our affiliates: %a.', array('%s' => variable_get('site_name', 'local'), '%a' => implode(', ', user_auth_help_links()))); } if($GLOBALS['logintoboggan_denied'] == TRUE){ $form[] = array( '#type' => 'hidden', '#name' => 'destination', '#value' => logintoboggan_destination(), ); } } // The $_POST check is a temporary hack to make sure the user login block doesn't get processed if (($form_id == 'user_login_block') && isset($_POST['logintoboggan']['login_block'])) { $form = _logintoboggan_toggleboggan($form); } break; case 'user_register': $mail = variable_get('email_reg_confirm', 0); $pass = variable_get('reg_passwd_set', 0); if (!user_access('administer users') && ($mail || $pass)) { $form['#validate'] += array('logintoboggan_user_register_validate' => array()); $form['#submit'] = array('logintoboggan_user_register_submit' => array($form_id, &$form_values)); //Display a confirm email address box if option is enabled. if ($mail) { $form['conf_mail'] = array('#type' => 'textfield', '#title' => t('Confirm E-mail address'), '#size' => 30, '#maxlength' => 64, '#description' => t('Please re-type your email address to confirm it is accurate.'), '#required' => TRUE, ); } //Display a password and password confirm box if users can select their own passwords. if ($pass) { $form['pass'] = array('#type' => 'password', '#title' => t('Password'), '#size' => 30, '#maxlength' => 30, '#description' => t('Please choose a password for your account; it must be between 6 and 30 characters and spaces are not allowed.'), '#required' => TRUE, ); $form['conf_pass'] = array('#type' => 'password', '#title' => t('Confirm Password'), '#size' => 30, '#maxlength' => 30, '#description' => t('Please re-type your password to confirm it is accurate.'), '#required' => TRUE, ); } // Have to put these in the login form group if it's been created if (isset($form['account'])) { $form['account']['conf_mail'] = $form['conf_mail']; $form['account']['pass'] = $form['pass']; $form['account']['conf_pass'] = $form['conf_pass']; unset($form['conf_mail']); unset($form['pass']); unset($form['conf_pass']); } } break; } } /** * Custom submit function for user registration form * * @ingroup logintoboggan_form */ function logintoboggan_user_register_submit($form_id, $form_values) { global $base_url; $admin = user_access('administer users'); $mail = $form_values['mail']; $name = $form_values['name']; //If we are allowing user selected passwords then skip the auto-generate function if (variable_get('reg_passwd_set', 0) || $admin) { $pass = $form_values['pass']; } else { $pass = user_password(); } $from = variable_get('site_mail', ini_get('sendmail_from')); if (!$admin && array_intersect(array_keys($form_values), array('uid', 'roles', 'init', 'session', 'status'))) { watchdog('security', t('Detected malicious attempt to alter protected user fields.'), WATCHDOG_WARNING); drupal_goto('user/register'); } $reg_pass_set = variable_get('reg_passwd_set', 0); // Set validating id $validating_id = $reg_pass_set ? logintoboggan_validating_id() : $DRUPAL_AUTHENTICATED_RID; $account = user_save('', array_merge($form_values, array('pass' => $pass, 'init' => $mail, 'roles' => array($validating_id), 'status' => $admin || variable_get('user_register', 1)))); watchdog('user', t('New user: %name %email.', array('%name' => theme('placeholder', $name), '%email' => theme('placeholder', '<'. $mail .'>'))), WATCHDOG_NOTICE, l(t('edit'), 'user/'. $account->uid .'/edit')); $login_url = $reg_pass_set ? logintoboggan_eml_validate_url($account) : user_pass_reset_url($account); $variables = array('%username' => $name, '%site' => variable_get('site_name', 'drupal'), '%password' => $pass, '%uri' => $base_url, '%uri_brief' => substr($base_url, strlen('http://')), '%mailto' => $mail, '%date' => format_date(time()), '%login_uri' => url('user', NULL, NULL, TRUE), '%edit_uri' => url('user/'. $account->uid .'/edit', NULL, NULL, TRUE), '%login_url' => $login_url); // The first user may login immediately, and receives a customized welcome e-mail. if ($account->uid == 1) { user_mail($mail, t('drupal user account details for %s', array('%s' => $name)), strtr(t("%username,\n\nYou may now login to %uri using the following username and password:\n\n username: %username\n password: %password\n\n%edit_uri\n\n--drupal"), $variables), "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"); drupal_set_message(t('

Welcome to Drupal. You are user #1, which gives you full and immediate access. All future registrants will receive their passwords via e-mail, so please make sure your website e-mail address is set properly under the general settings on the settings page.

Your password is %pass. You may change your password below.

', array('%pass' => $pass, '%settings' => url('admin/settings')))); user_authenticate($account->name, trim($pass)); drupal_goto('user/1/edit'); } else { if ($admin) { drupal_set_message(t('Created a new user account. No e-mail has been sent.')); drupal_goto('admin/user'); } else if ($account->status) { // Create new user account, no administrator approval required. $subject = _user_mail_text('welcome_subject', $variables); $body = _user_mail_text('welcome_body', $variables); user_mail($mail, $subject, $body, "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"); if(variable_get('reg_passwd_set', 0)) { if (variable_get('reg_passwd_set', 0) == 2){ drupal_set_message(t('A validation email has been sent to your e-mail address. You will need to follow the instructions in that message in order to gain full access to the site.')); logintoboggan_process_login($account); } drupal_set_message(t('A validation email has been sent to your e-mail address. You will need to follow the instructions in that message in order to gain full access to the site.')); drupal_goto(); } else { drupal_set_message(t('Your password and further instructions have been sent to your e-mail address.')); drupal_goto(); } } else { // Create new user account, administrator approval required. $subject = _user_mail_text('approval_subject', $variables); $body = _user_mail_text('approval_body', $variables); user_mail($mail, $subject, $body, "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"); user_mail(variable_get('site_mail', ini_get('sendmail_from')), $subject, t("%u has applied for an account.\n\n%uri", array('%u' => $account->name, '%uri' => url("user/$account->uid/edit", NULL, NULL, TRUE))), "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"); drupal_set_message(t('Thank you for applying for an account. Your account is currently pending approval by the site administrator.
In the meantime, your password and further instructions have been sent to your e-mail address.')); drupal_goto(); } } } /** * Custom validation for user login form * * @ingroup logintoboggan_form */ function logintoboggan_user_login_validate($form_id, $form_values) { if (isset($form_values['name']) && variable_get('login_with_mail', 0)) { if (user_is_blocked($form_values['name'])) { // blocked in user administration form_set_error('login', t('The username %name has been blocked.', array('%name' => theme('placeholder', $form_values['name'])))); } else if (drupal_is_denied('user', $form_values['name'])) { // denied by access controls form_set_error('login', t('The name %name is a reserved username.', array('%name' => theme('placeholder', $form_values['name'])))); } else if ($form_values['pass']) { $user = logintoboggan_authenticate($form_values['name'], trim($form_values['pass'])); if (!$user->uid) { form_set_error('login', t('Sorry. Unrecognized username or password.') .' '. l(t('Have you forgotten your password?'), 'user/password')); watchdog('user', t('Login attempt failed for %user: %error.', array('%user' => theme('placeholder', $form_values['name']), '%error' => theme('placeholder', $error)))); drupal_goto('user/login'); } } } } /** * Custom validation function for user registration form * * @ingroup logintoboggan_form */ function logintoboggan_user_register_validate($form_id, $form_values) { if (variable_get('login_with_mail', 0)) { // check that it's not an email if (valid_email_address($form_values['name'])) { form_set_error('name', t('You may not use an email address as your username.')); } } //Check to see whether our email address matches the confirm address if enabled. if (variable_get('email_reg_confirm', 0)) { if ($form_values['mail'] != $form_values['conf_mail']) { form_set_error('conf_mail', t('Your email address and confirmed email address must match.')); } } //Do some password validation if password selection is enabled. if (variable_get('reg_passwd_set', 0)) { if ($form_values['pass'] != $form_values['conf_pass']) { form_set_error('conf_pass', t('Your password and confirmed password must match.')); } $pass_err = logintoboggan_validate_pass($form_values['pass']); if ($pass_err) { form_set_error('conf_pass', $pass_err); } } } /** * Implementation of hook_menu() * * @ingroup logintoboggan_core */ function logintoboggan_menu($may_cache) { global $user; $items = array(); if ($may_cache) { //callback for user validate routine $items[] = array('path' => 'user/validate', 'title' => t('validate email address'), 'callback' => 'logintoboggan_validate_email', 'access' => TRUE, 'type' => MENU_CALLBACK, ); //callback for handling access denied redirection $items[] = array('path' => 'toboggan/denied', 'access' => TRUE, 'callback' => 'logintoboggan_denied', 'title' => t('access denied'), 'type' => MENU_CALLBACK, ); } else { //callback for re-sending validation e-mail $items[] = array('path' => 'toboggan/revalidate', 'title' => t('re-send validation e-mail'), 'callback' => 'logintoboggan_resend_validation', 'callback arguments' => arg(2), 'access' => $user->uid == arg(2), 'type' => MENU_CALBACK, ); } return $items; } /** * @defgroup logintoboggan_block Functions for LoginToboggan blocks. */ /* This will be used later when the conversion to using the user login block is complete function logintoboggan_user_block_admin_configure_submit($form_id, $form_values) { toboggan_block_msg variable_set('toboggan_block_type', $form_values['toboggan_block_type']); variable_set('toboggan_display_logged_in', $form_values['toboggan_display_logged_in']); variable_set('toboggan_block_msg', $form_values['toboggan_block_msg']); }*/ /** * Implementation of hook_block */ function logintoboggan_block($op = 'list', $delta = 0, $edit = array()) { global $user; switch ($op) { case 'list' : $blocks[0]['info'] = t('LoginToboggan custom login'); return $blocks; break; case 'configure': if ($delta == 0){ $form['toboggan_display_logged_in'] = array('#type' => 'checkbox', '#title' => t('Display the \'logged in\' block'), '#default_value' => variable_get('toboggan_display_logged_in', 1), ); $form['toboggan_block_type'] = array('#type' => 'radios', '#title' => t('Block type'), '#default_value' => variable_get('toboggan_block_type', 1), '#options' => array(t('Link'), t('Collapsible Form')), ); $form['toboggan_block_msg'] = array('#type' => 'textarea', '#title' => t('Set a custom message to appear at the top of your login block'), '#default_value' => variable_get('toboggan_block_msg', ''), ); return $form; } break; case 'save' : if ($delta == 0){ variable_set('toboggan_block_type', $edit['toboggan_block_type']); variable_set('toboggan_display_logged_in', $edit['toboggan_display_logged_in']); variable_set('toboggan_block_msg', $edit['toboggan_block_msg']); } break; case 'view' : switch ($delta) { case 0: // For usability's sake, avoid showing two login forms on one page. if (!$user->uid && !(arg(0) == 'user' && !is_numeric(arg(1)))) { if (variable_get('toboggan_block_type', 1) == 1) { // A temporary hack to make sure the user login block itself doesn't get altered as well $_POST['logintoboggan']['login_block'] = TRUE; // Calling the user login block here directly in order to be able to use the form and alter it for our needs. // We also have to unset the ugly title from the user block $block = user_block('view', 0); unset($block['subject']); } else { $block['content'] = l(t('Login/Register'), 'user/login', array(), drupal_get_destination()); } } elseif ($user->uid && variable_get('toboggan_display_logged_in', 1)) { $block['content'] = theme('lt_loggedinblock'); } return $block; } break; } } /** * Custom theme function for defining what gets displayed for logged in users. * */ function theme_lt_loggedinblock(){ global $user; return $user->name .' | ' . l(t('log out'), 'logout'); } /** * User login block with JavaScript to expand * * this should really be themed * * @return array * the reconstituted user login block */ function _logintoboggan_toggleboggan ($form) { $pre = '
'; $pre .= l(t('Login/Register'), 'toboggan/login', array('onclick' => "toggleboggan('toboggan_login');this.blur();return false;")); //Grab the message from settings if there is one to display at the top of the login block. if ($login_msg = variable_get('toboggan_block_msg', '')) { $pre .= '
'. $login_msg .'
'; } //the block that will be toggled $pre .= '
'; $form['pre'] = array('#value' => $pre, '#weight' => -300); $post .= '
'; //javascript toggle function $post .= ''; $form['post'] = array('#value' => $post, '#weight' => 300); return $form; } function logintoboggan_settings() { $version .= str_replace(array('$Re'.'vision:', '$Da'.'te:', '$'), array('', '', ''), '

Login Toboggan version: $Revision$, $Date$

'); $form['login'] = array('#type' => 'fieldset', '#title' => t('Login'), '#prefix' => $version, ); $form['login']['login_with_mail'] = array('#type' => 'radios', '#title' => t('Allow users to login using their email address'), '#default_value' => variable_get('login_with_mail', 0), '#options' => array(t('disabled'), t('enabled')), '#description' => t('Users will be able to enter EITHER their username OR their email address to log in. note: This will disallow users from registering using an email address as their username.'), ); $form['registration'] = array('#type' => 'fieldset', '#title' => t('Registration'), ); $form['registration']['email_reg_confirm'] = array('#type' => 'radios', '#title' => t('Use two email fields on registration form'), '#default_value' => variable_get('email_reg_confirm', 0), '#options' => array(t('disabled'), t('enabled')), '#description' => t('User will have to type the same email address into both fields. This helps to confirm that they\'ve typed the correct address.'), ); $form['registration']['reg_passwd_set'] = array('#type' => 'radios', '#title' => t('Allow user to set their password during registration'), '#default_value' => variable_get('reg_passwd_set', 0), '#options' => array(t('Disabled'), t('Set Password'), t('Set password & Immediate login')), '#description' => t('This will allow users to choose their initial password when registering. If \'Set password & Immediate login\' is selected, users will be assigned to the role below and logged in immediately. They will not be assigned to the "athenticated user" role until they confirm their email address by following the link in their registration email. It is HIGHLY recommended that you set up a "pre-authorized" role with limited permissions for this purpose.
NOTE: If you enable either of these features, you should edit the %settings--more help in writing the email message can be found %help.', array('%settings' => l('user email welcome message', 'admin/settings/user'), '%help' => l('logintoboggan help', 'admin/help/logintoboggan'))), ); $form ['registration']['toboggan_role'] = array('#type' => 'select', '#title' => t('Non-authenticated role'), '#options' => user_roles(), '#default_value' => variable_get('toboggan_role', 1), '#description' => t('If either "Set password during registration" or "Immediate login" is selected, users will be able to login before their email address has been authenticated. Therefore, you must choose a role for new non-authenticated users. Users will be removed from this role and assigned to the "authenticated user" once they follow the link in their welcome email. Add new roles here.', array('%url' => url('admin/access/roles'))), ); $form['other'] = array('#type' => 'fieldset', '#title' => t('Other'), '#tree' => FALSE, ); $site403 = variable_get('site_403', ''); if ($site403 == 'toboggan/denied'){ $disabled = ''; } else { $disabled = $site403; } $options = array($disabled => t('disabled'), 'toboggan/denied' => t('enabled')); $form['other']['site_403'] = array( '#type' => 'radios', '#title' => t('Present login form on access denied (403)'), '#options' => $options, '#default_value' => $site403, '#description' => t('Anonymous users will be presented with a login form along with an access denied message.') ); return $form; } /** * Wrapper for user_authenticate() * - allows users to login using their email address */ function logintoboggan_authenticate($name, $pass) { // first see if $name is a valid username $account = user_load(array('name' => $name)); // if not, see if user is logging in with a user's email address if (!$account->uid && variable_get('login_with_mail', 0)) { if($account = user_load(array('mail' => $name))) { $name = $account->name; } } // hand it off to user_authenticate for the good stuff return user_authenticate($name, $pass); } function logintoboggan_denied() { global $user; if ($user->uid == 0) { $msg = t('Access Denied. You may need to log in to access this page.'); drupal_set_title(t('Access Denied / User Login')); // set up the tabs $item[] = array('path' => 'user/login', 'title' => t('Access Denied')); menu_set_location($item); global $logintoboggan_denied; $logintoboggan_denied = TRUE; $return = user_login($msg); } else { drupal_set_title(t('Access Denied')); $return = theme('lt_access_denied'); } return $return; } // Themeable function so that the access denied message can be customized function theme_lt_access_denied() { return t('You are not authorized to access this page.'); } // slight rewrite of drupal_get_destination() // with custom 403, drupal_get_destination() would return toboggan/denied // which would show 'Access Denied' after login... what good is that!? function logintoboggan_destination() { // Drupal has reset $_GET[q], so we need a workaround. if ($uri = request_uri()) { $uriarray = explode('/', $uri); array_shift($uriarray); if (!variable_get('clean_url', 0)) { $uriarray[0] = str_replace('?q=', '', $uriarray[0]); } $destination = implode('/', $uriarray); } else { // can't get uri? // so we'll fallback to user account page $destination = 'user'; } $output = $destination; return $output; } /** * Modified version of user_validate_name * - validates user submitted passwords have a certain length and only contain letters or numbers */ function logintoboggan_validate_pass($pass) { if (!strlen($pass)) return t('You must enter a password.'); if (ereg(' ', $pass)) return t('The password cannot contain spaces.'); if (ereg("[^\x80-\xF7 [:alnum:]@_.-]", $pass)) return t('The password contains an illegal character.'); if (preg_match('/[\x{80}-\x{A0}'. // Non-printable ISO-8859-1 + NBSP '\x{AD}'. // Soft-hyphen '\x{2000}-\x{200F}'. // Various space characters '\x{2028}-\x{202F}'. // Bidirectional text overrides '\x{205F}-\x{206F}'. // Various text hinting characters '\x{FEFF}'. // Byte order mark '\x{FF01}-\x{FF60}'. // Full-width latin '\x{FFF9}-\x{FFFD}]/u', // Replacement characters $pass)) { return t('The password contains an illegal character.'); } if (strlen($pass) > 30) return t('The password is too long: it must be less than 30 characters.'); if (strlen($pass) < 6) return t('The password is too short: it must be greater than 6 characters.'); } /** * Modified version of $DRUPAL_AUTHENTICATED_RID * - gets the role id for the "validating" user role. */ function logintoboggan_validating_id() { return variable_get('toboggan_role', 1); } /** * Menu callback; process validate the email address as a one time URL, * and redirects to the user page on success. */ function logintoboggan_validate_email($uid, $timestamp, $hashed_pass) { global $user; $current = time(); // Some redundant checks for extra security if ($timestamp < $current && is_numeric($uid) && $account = user_load(array('uid' => $uid, 'status' => 1)) ) { // No time out for first time login. if ($account->uid && !empty($account) && $timestamp < $current && $hashed_pass == logintoboggan_eml_rehash($account->pass, $timestamp, $account->mail)) { watchdog('user', t('Email validation URL used for %name with timestamp %timestamp.', array('%name' => "$account->name", '%timestamp' => $timestamp))); // Update the user table noting user has logged in. // And this also makes this hashed password a one-time-only login. db_query("UPDATE {users} SET login = '%d' WHERE uid = %d", time(), $account->uid); db_query("UPDATE {users_roles} SET rid ='%d' WHERE uid = %d AND rid = %d", $DRUPAL_AUTHENTICATED_RID, $account->uid, logintoboggan_validating_id()); // Now we can set the new user. $user = $account; // And proceed with normal login, going to user page. drupal_set_message(t("You have successfully validated your email address.")); logintoboggan_process_login($user); } } // Deny access, no more clues. // Everything will be in the watchdog's URL for the administrator to check. drupal_access_denied(); } /** * Actually log the user on * * @param object $account */ function logintoboggan_process_login($account){ global $user; $user = $account; watchdog('user', t('Session opened for %name.', array('%name' => theme('placeholder', $user->name)))); // Update the user table timestamp noting user has logged in. db_query("UPDATE {users} SET login = '%d' WHERE uid = '%s'", time(), $user->uid); // user has new permissions, so we clear their menu cache cache_clear_all('menu:'. $user->uid, TRUE); user_module_invoke('login', $edit, $user); drupal_goto('user/'. $user->uid); } function logintoboggan_eml_validate_url($account){ $timestamp = time(); return url("user/validate/$account->uid/$timestamp/".logintoboggan_eml_rehash($account->pass, $timestamp, $account->mail), NULL, NULL, TRUE); } function logintoboggan_eml_rehash($password, $timestamp, $mail){ return md5($timestamp . $password . $mail); } /** * Implementation of hook_user(). */ function logintoboggan_user($op, &$edit, &$user_edit, $category = NULL) { global $user; if ($op == 'form' && $category == 'account' && $user->uid == arg(1)) { // User is editing their own account settings if (variable_get('reg_passwd_set', 0) == 2 && array_key_exists(logintoboggan_validating_id(), $user_edit->roles)) { // User is still in pre-authorized role; display link to re-send e-mail. $form['revalidate'] = array( '#type' => 'fieldset', '#title' => t('Account validation'), '#weight' => -10, ); $form['revalidate']['revalidate_link'] = array( '#value' => l(t('re-send validation e-mail'), 'toboggan/revalidate/'. $user_edit->uid), ); return $form; } } } /** * Re-sends validation e-mail to user specified by $uid. */ function logintoboggan_resend_validation($uid) { global $base_url; $account = user_load(array('uid' => $uid)); // Variables to replace in e-mail $pass = t('If required, you may reset your password from: %url', array('%url' => url('user/password', NULL, NULL, TRUE))); $variables = array('%username' => $account->name, '%site' => variable_get('site_name', 'drupal'), '%password' => $pass, '%uri' => $base_url, '%uri_brief' => substr($base_url, strlen('http://')), '%mailto' => $account->mail, '%date' => format_date(time()), '%login_uri' => url('user', NULL, NULL, TRUE), '%edit_uri' => url('user/'. $account->uid .'/edit', NULL, NULL, TRUE), '%login_url' => logintoboggan_eml_validate_url($account)); // Prepare and send e-mail. $from = variable_get('site_mail', ini_get('sendmail_from')); $subject = _user_mail_text('welcome_subject', $variables); $body = _user_mail_text('welcome_body', $variables); user_mail($account->mail, $subject, $body, "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"); // Notify user that e-mail was sent and return to user edit form. drupal_set_message(t('A validation email has been sent to your e-mail address. You will need to follow the instructions in that message in order to gain full access to the site.')); drupal_goto('user/'. $account->uid .'/edit'); }