I need to register my users to a 3rd party service upon registration in Drupal. I have toyed around a bit with hooks, and tried to catch the password upon registration so I can insert it into another database, but to no avail. The 3rd party DB encrypts the password in a different way, so I need to get the users password in clear text, crypt it and then save it to the database.

Can anyone give me some pointers to where I should look? hook_user_insert (&$edit, $account, $category), both $edit and $account contains the users encrypted drupal passwords.

1 Answer 1


When a form is submitted, its values are validated by the functions listed in $form['#validate'] then processed by the functions in $form['#submit']. If there is no $form['#validate'], then the function FORM_NAME_validate will run (if any). Same for submit.

See user_register_submit. The plain text password is in $form_state['values']['pass']. Write a hook_form_alter and add a new submit function to $form['#submit']. Declare that function and put the logic you need in it.

  • Thanks for the feedback, but I just need some clarification. A hook_form_alter function is just to alter/add elements in a page? So why write a hook_form_alter function? A new submit ... you mean a hook_form_validate function? As I know thats the only function that operates after submission that you can alter $form_state and $form.
    – laban
    Commented Aug 11, 2011 at 12:20
  • I hope I have clarified things in the answer. Commented Aug 11, 2011 at 13:09
  • 1
    Yes, very much so! I'm going to register now just to give you a thumbs up. Who's awsome? You are;-)
    – laban
    Commented Aug 11, 2011 at 13:18

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.