4

I want to know the Request New Password form id. (www.example.com/user/password).
I found out that the register form is "user_register_form" and tried same for password (user_password_form / user_pass_form / user_pass_reset) but nothing worked.

Hope you can help me! Thanks a lot!

Edit: If you could tell me the account form id in the same breathe, the answer would be simply awesome.

  • Are you in Drupal 6 or 7? – nedwardss Aug 12 '12 at 19:21
  • I'am using Drupal 7. – Leandros Aug 12 '12 at 20:26
  • 1
    What is the path of the "account" page to which you refer (excluding your base_url)? – nedwardss Aug 16 '12 at 0:13
  • 1
    I probably do, what's the path of the form (excluding base_url)? Or are you referring to the user profile page itself? – nedwardss Aug 16 '12 at 0:22
  • 1
    The form id on that page is 'user_profile_form'. If there is a bunch of stuff you need to do, you might better off opening a new question. Otherwise, I can answer quickly here. Or edit my existing answer. – nedwardss Aug 16 '12 at 0:38
3

Note that print_r will be better in this case because to see the form he desires one must be logged out otherwise you'll get the password reset for the active user, which is different.

Leandros, try putting this in your theme's template.php and visiting user/password (not logged in)

function YOURTHEMENAME_form_alter(&$form, &$form_state, $form_id) {
  switch ($form_id) {
    case 'user_pass':
        print '<pre>';print_r($form); print '</pre>';
      break; 
  }
}

It will give you an array of everything that's in there. Then, say you wanted to change the text "Username or e-mail address" and the text on the submit button you could do this:

function YOURTHEMENAME_form_alter(&$form, &$form_state, $form_id) {
  switch ($form_id) {
    case 'user_pass':
        //print '<pre>';print_r($form); print '</pre>';
        $form['name']['#title'] = 'Please type your username/email quickly.';
        $form['actions']['submit']['#value'] = 'Email it to me!';
      break; 
  }
}
  • 1
    The access devel information permission also can give access to anonymous users to see the devel messages. – rooby Mar 16 '14 at 1:37
  • Absolutely @rooby , good call. Just don't forget to uncheck the permission or, better yet, uninstall Devel altogether, before you go to production. Could leave a big security hole there... – nedwardss Mar 22 '14 at 4:58
1

install the Devel module. Then implement hook_form_alter() and use dpm().

Then goto any page you want to see a form details on, you will see it in the System Messages block.

function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
  dpm($form, '$form info for $form_id '.$form_id);  
}
  • Thanks! The form id is 'user_pass', but if I implement the form I get that error Notice: Undefined index: user_pass in drupal_retrieve_form() (line 765 of /var/www/********/htdocs/includes/form.inc). Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'user_pass' not found or invalid function name in drupal_retrieve_form() (line 800 of /var/www/********/htdocs/includes/form.inc). – Leandros Aug 12 '12 at 18:45
  • I am not sure what you're trying to do to the user_pass_form. You shouldnt have to implement it yourself, you should be able to alter the form on the page with hook_form_alter() to add your own validation, form items, etc ... – tenken Aug 13 '12 at 4:41
  • I did a panal layout with pages and wanted to implement it in my panel layout. – Leandros Aug 14 '12 at 13:59
0

The IDs for these are:

  • User register: user_register_form
  • User login: form_user_login
  • User pass: user_pass

I suggest you to use the hook_form_FORM_ID_alter.

e.g. For change something in the User pass form:

/**
 * Implements hook_form_user_pass_alter().
 */
function my_module_form_user_pass_alter($form, &$form_state) {
  // Change text button.
  $form['actions']['submit']['#value'] = t('Send password');
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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