I want to change the current user password, and get the new password(the real password, not md5 encryption) when edit the account profile via user profile form(e.g.: example.com/user/1/edit) and save. would anyone can tell me how to do that? I tried using hook_user_update(), but it didn't succeed.

I mean I want to change the current user password, and I want to get the new password.

2 Answers 2


Implement hook_form_alter() (or one of it relatives) such that it array_unshift() a new submission handler to the user update form. The submission handler should add the password to the $form_state['values'] array. You also have to add the same key to $form_state['user'], because of the way user_profile_form_submit() calculates which keys from $form_state['values'] to pass as $edit to your hook_user_update() implementation.

If you did not insist on using hook_user_update(), I'd suggest handling your custom additions to the password update directly in your submission handler.

By the way, Drupal 7 does not use a simple MD5 hash to store passwords.

  • 1
    I'm not going to add another answer, as the useful bit is already here - but there is no way to get a readable password out of Drupal. To quote Kiamlaluno from here: Drupal doesn't encrypt the password and [save] it in the database, but it saves in database the hash of the password, which is the value returned from a one-way function;
    – Chapabu
    Commented Sep 27, 2012 at 8:12
  • I try to add a drupal_set_message($form_state['values']['pass']) to the function user_profile_form_submit, and return the real password. but I dont want to hark code, so I want to get it on other customize module.
    – Brian Lau
    Commented Sep 27, 2012 at 8:13
  • I just want to receive the new password via form widget (drupal 7 this widget's id is :edit-pass-pass1), and use this password to single sign on with other system. In order to make data synchronization,when password has changed, another system will changed at the same time.
    – Brian Lau
    Commented Sep 27, 2012 at 8:19

How about reading it directly from $_REQUEST array? I've added code like this:

function hook_user_presave(&$edit, $account, $category){
 echo $_REQUEST['pass']['pass1'];

and it works.

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.