function user_login

You are here

7 user.module user_login($form, &$form_state)
4.6 user.module user_login($edit = array(), $msg = '')
4.7 user.module user_login($msg = '')
5 user.module user_login()
6 user.module user_login(&$form_state)
2 string references to 'user_login'
user_block in modules/user.module
Implementation of hook_block().
user_menu in modules/user.module
Implementation of hook_menu().

File

modules/user.module, line 889
Enables the user registration and login system.

Code

function user_login($msg = '') {
  global $user, $base_url;

  // If we are already logged on, go to the user page instead
  if ($user->uid) {
    drupal_goto('user/' . $user->uid);
  }

  // Display login form:
  if ($msg) {
    $form['message'] = array('#value' => '<p>' . check_plain($msg) . '</p>');
  }
  unset($_GET['time']);
  $form['#action'] = url($_GET['q'], drupal_get_destination());
  $form['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Username'),
    '#size' => 30,
    '#maxlength' => 60,
    '#required' => TRUE,
    '#attributes' => array('tabindex' => '1'),
  );
  if (variable_get('drupal_authentication_service', FALSE) && count(user_auth_help_links()) > 0) {
    $form['name']['#description'] = t('Enter your %s username, or an ID from one of our affiliates: %a.', array('%s' => variable_get('site_name', 'local'), '%a' => implode(', ', user_auth_help_links())));
  }
  else {
    $form['name']['#description'] = t('Enter your %s username.', array('%s' => variable_get('site_name', 'local')));
  }
  $form['pass'] = array(
    '#type' => 'password',
    '#title' => t('Password'),
    '#description' => t('Enter the password that accompanies your username.'),
    '#required' => TRUE,
    '#attributes' => array('tabindex' => '2'),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Log in'),
    '#weight' => 2,
    '#attributes' => array('tabindex' => '3'),
  );
  return drupal_get_form('user_login', $form);
}