Search code examples
phpdrupal-7

How to programmatically check if password is valid in Drupal 7?


I am using Drupal 7 and creating a custom form to update user password. Before i have to check if the old password user give really is the user password.

Is there a way to do this in Drupal 7?

Thank's for your help!


Solution

  • Using user_check_password does the trick :

    user_check_password($user_old_password, $user)
    

    Return true if the old password matched the password associated with the user object.