How would I go about changing the input field value from e.g. 15 to 10 in the default User Login Block for Username and Password fields, using Hook Form Alter?

  • Whats the question ? You want to change ? or you want to know what happens after its changing ?
    – niksmac
    Commented Aug 9, 2013 at 8:42
  • I want to change the input field value for username and password in the User Login Block from 15 to 10. But I don't want to create a new template file, I want to use the Hook Form Alter option. Commented Aug 9, 2013 at 11:58

1 Answer 1


Put this in your module:

function mymodule_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'user_login_block') {
    $form['name']['#size'] = 10;
    $form['pass']['#size'] = 10;

Also hook_form_user_login_block_alter can be used, then you don't need to check the form_id.

Remember to clear the cache, if you are not already using hook_form_alter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.