how to get password as submitted by the user in hook_user_insert? I have extended the core using hook_user_insert. but when i print the $edit argument inside the function i get password fields as encrypted.

Is there any way i can get the non-encrypted value of password as submitted by the user.

I am using drupal 7

Following is the $edit array

Array
(
    [uid] =&gt; 28
    [hostname] =&gt; 127.0.0.1
    [roles] =&gt; Array
        (
            [2] =&gt; authenticated user
        )

    [cache] =&gt; 0
    [administer_users] =&gt; 
    [name] =&gt; raul1
    [mail] =&gt; raul1@tst.com
    [pass] =&gt; $S$DskyNMYOrdQoEdErlYPN701I1jSBBrzetjSjb2XPzlooVcfcp8Rp
    [status] =&gt; 
    [notify] =&gt; 0
    [timezone] =&gt; Asia/Kolkata
    [signature] =&gt; 
    [picture] =&gt; 
    [picture_delete] =&gt; 0
    [picture_upload] =&gt; 
    [signature_format] =&gt; filtered_html
    [init] =&gt; raul1@tst.com
    [field_first_name] =&gt; Array
        (
            [und] =&gt; Array
                (
                    [0] =&gt; Array
                        (
                            [value] =&gt; Raul
                        )

                )

        )

    [field_last_name] =&gt; Array
        (
            [und] =&gt; Array
                (
                    [0] =&gt; Array
                        (
                            [value] =&gt; Garcia
                        )

                )

        )

    [is_new] =&gt; 1
    [created] =&gt; 1356067366
    [theme] =&gt; 
    [access] =&gt; 0
    [login] =&gt; 0
    [language] =&gt; 
)


is there any tweaking to get the user submitted password from D7 registration form?

I know its impossible to get back the hashed value. or how to find out the salt associated with each hashed password
Any hook that is invoked from user_save() is too late to get the password as entered from the user. In fact, the first lines executed from user_save() are the following ones.

if (!empty($edit['pass'])) {
  // Allow alternate password hashing schemes.
  require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc');
  $edit['pass'] = user_hash_password(trim($edit['pass']));
  // Abort if the hashing failed and returned FALSE.
  if (!$edit['pass']) {
    return FALSE;
  }
}


What you can do is adding a form submission handler to the form used to create new user accounts. That submission handler can access the password as entered from the user in $form_state['values']['pass']. I would rather add a form submission handler that is executed right after user_register_submit(), as that submission handler contains the following code.

  if (!variable_get('user_email_verification', TRUE) || $admin) {
    $pass = $form_state['values']['pass'];
  }
  else {
    $pass = user_password();
  }
  $notify = !empty($form_state['values']['notify']);

  // Remove unneeded values.
  form_state_values_clean($form_state);

  $form_state['values']['pass'] = $pass;


I would use the following code.

function mymodule_form_user_register_form_alter(&amp;$form, &amp;$form_state) {
  // Add your submission handler.
  $form['#submit'][] = 'mymodule_user_register_submit';
}

function mymodule_user_register_submit(&amp;$form, &amp;$form_state) {
  // The password is in $form_state['values']['pass'].
}