Hi guys.

I try to remove this text line: "Request new password"?
how to do that?

i would also like to change width of username and passwords forms.

just don't know how to do that?

Comments

dwees’s picture

You want to create a tiny module, and use the Drupal function hook_form_alter to fix this form.

Dave

mrksr’s picture

I hardly understand how this api thing works but not so sure can i do it.

I'm usin drupal 5 and all i found whas this for drupal 4.7

http://drupal.org/node/78243

how do I do the mini module and simple user login with drupal 5?

dwees’s picture

/**
* Implementation of hook_help().
*/
function loginmod_help($section) {
  switch ($section) {
    case 'admin/modules#description':
      return t('Makes login block collapsible');
  }
}

/**
* Implementation of hook_form_alter().
*/
function loginmod_form_alter($form_id, &$form) {
  if ($form_id == 'user_login_block'){
       unset($form['links']);
       $items = array();
       if (variable_get('user_register', 1)) {
           $items[] = l(t('Create new account'), 'user/register', array('title' => t('Create a new user account.')));
       }
       $form['links'] = array('#value' => theme('item_list', $items)); 
  }
}

Save this as loginmod.module and create a separate file called 'loginmod.info' with the following inside it:

; $Id$
name = Loginmod
description = This module changes the default login block so it doesn't contain the 'request new password' field.

Put both of these files into a folder called 'loginmod' and upload it into the modules directory of your website, and upload it. Then enable the module. If you have any problems with it, you can delete the module folder.

Dave

mrksr’s picture

You solved my problem! you are the man!

I just have one problem anymore.

log in button text. I need to change it bit loger word. and when i change it the width of my log in button won't change. I can only see couple of letters of it. ?

dwees’s picture

Take a look http://api.drupal.org and look up the function 'user_login_form' to see what form fields are set in this function. Find the one you want to change, and I bet it has a line in it like: '#size' => 20, or something like that.

Copy the entire form element to your custom function, put an unset of the form variable (like I did in the previous example) and then paste the code below that line, and modify the #size attribute to what you want.

Hope this makes sense.

Dave

nonsparker’s picture

Thanks a bunch Dave, I used this as well and it works great!

ikkunaprincessa’s picture

thx
it worked for me 2

Dr Trichome’s picture

Hi Dwees,

I ported your module to Drupal 6 using the online version of Deadwood here. It works great. Thanks for a very useful module.

Here is loginmod.info (same as previous version)

; $Id$
name = Loginmod
description = This module changes the default login block so it doesn't contain the 'request new password' field.
core = 6.x

Here is loginmod.module

/**
* Implementation of hook_help().
*/
function loginmod_help($path, $arg) {
  switch ($path) {
    case 'admin/modules#description':
      return t('Makes login block collapsible');
  }
}

/**
* Implementation of hook_form_alter().
*/
function loginmod_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'user_login_block'){
       unset($form['links']);
       $items = array();
       if (variable_get('user_register', 1)) {
           $items[] = /* TODO
   Please manually fix the parameters on the l() or url() function on the next line.
   Typically, this was not changed because of a function call inside an array call like
   array('title' => t('View user profile.')).*/
l(t('Create new account'), 'user/register', array('title' => t('Create a new user account.')));
       }
       $form['links'] = array('#value' => theme('item_list', $items));
  }
}

Oops. I see that I am supposed to fix something in the module from the comments added by Deadwood. Unfortunately, I do not know enough php to do this. I have installed this module and it appears to be working. Any help would be appreciated.

f0ns’s picture

thanks alot!

I was planning to write this myself but hey! it's made allready so I can use my time to do other stuff ;) thanks!

emijayne’s picture

thank you thank you thank you!!! :D

jmmec’s picture

Even simpler is to use the core "locale" module and create a new translation for the text you want to change:

http://drupal.org/node/24593

drupal_jay’s picture

I've been searching for solutions to this, and none of which I had come across worked. This just worked and the explanation is really straight forward. Thanks!

ttosttos’s picture

The loginmod module described above addresses the user login block. However, it doesn't address the login page (yoursite.com/user/login)
http://drupal.org/node/68792 seems to provide indications on how to take care of the latter.