5.x user.module user_login_block()
6.x user.module user_login_block()
7.x user.module user_login_block($form)
1 string reference to 'user_login_block'
user_block_view in modules/user/user.module
Implements hook_block_view().


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


function user_login_block($form) {
  $form['#action'] = url(current_path(), array('query' => drupal_get_destination(), 'external' => FALSE));
  $form['#id'] = 'user-login-form';
  $form['#validate'] = user_login_default_validators();
  $form['#submit'][] = 'user_login_submit';
  $form['name'] = array('#type' => 'textfield',
    '#title' => t('Username'),
    '#maxlength' => USERNAME_MAX_LENGTH,
    '#size' => 15,
    '#required' => TRUE,
  $form['pass'] = array('#type' => 'password',
    '#title' => t('Password'),
    '#size' => 15,
    '#required' => TRUE,
  $form['actions'] = array('#type' => 'actions');
  $form['actions']['submit'] = array('#type' => 'submit',
    '#value' => t('Log in'),
  $items = array();
  if (variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL)) {
    $items[] = l(t('Create new account'), 'user/register', array('attributes' => array('title' => t('Create a new user account.'))));
  $items[] = l(t('Request new password'), 'user/password', array('attributes' => array('title' => t('Request new password via e-mail.'))));
  $form['links'] = array('#markup' => theme('item_list', array('items' => $items)));
  return $form;


arellani’s picture

I am using Drupal 7 with pixture reloaded theme.

The block user login shows on the dscription line the word "Array".

how can I fix that? I did not change anything on the user.module or page.tpl.php or template.tpl.php.

The only change i made it is install the automatic log out module, but at first every was OK.

Best regards


rayjames’s picture

arellani - when you see something that shows up as array, then you need to render it to the page, like this:


Ton more info here -> https://drupal.org/node/930760

stillfire’s picture

Hey, I am having issues displaying error messages with the user_login_block, and I would like it to redirect to the default user page and display validation errors on fail.

I have created a custom module and this is the code.. The redirect isn't working though.

function login_fail_form_alter(&$form, $form_state, $form_id) {
  switch ($form_id) {
    case 'user_login_block':
      $form['#validate'][] = 'my_custom_login_val';

function my_custom_login_val($form, &$form_state) {
  $form = form_get_error($form['name']) . form_get_error($form['pass']);
  if($form != '') {
	   $_GET['destination'] = 'user';

Thanks in advance.