Drupal Answers is a question and answer site for Drupal developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Thanks a lot for your posting about building a form on its own to change user password. I used your suggested approach and I coud implement easily many isolated forms to let people change password, avatar, and so on.

What I cannot solve is how to use the same logic to reset forgotten password on a form on its own called from the one-time login link.

I tried this: - I installed module Login Destinations and added the following destination rule triggered on one-time login link:

    global $user; 
    // Let the user's password be changed without the current password check.
    $token = drupal_hash_base64(drupal_random_bytes(55));
    $_SESSION['pass_reset_' . $user->uid] = $token;
    return array('change-password', array('query' => array('pass-reset-token' => $token)));

It is triggered from user/reset/*.

  • change-password is my custom form implemented like this.

    function _tb_user_render_user_pass_set_new_form() {
      global $user;
      if (!user_is_logged_in()) {
      module_load_include('inc', 'user', 'user.pages');
      $form = drupal_get_form('user_profile_form', $user);
      $children = element_children($form);
      foreach ($children as $child) {
        if (!($child == 'account' || $child == 'actions' || $child == 'form_build_id' || $child == 'form_token' || $child == 'form_id' || $child == 'current_id' || $child == 'revision_id' || $child == 'current_date')) {
      $children = element_children($form['account']);
      foreach ($children as $child) {
        if (!($child == 'current_pass_required_values' || $child == 'pass')) {
      return $form;

It does't work since it still requires current password.

Do you have any idea on how to do that properly?

share|improve this question
This might help. If you just remove the validation handler and current password field it should do what you want – Clive Nov 18 '12 at 2:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.