I'm working with Drupal 7, the function **user_authenticate()** working fine with the default User module, but I have implemented a custom "user login" module, and I use this same function in that module, but somehow it is not working at all in this new module.

When we are using this function in default module, it's retrieving all the records based on the user parameters, but in my case it's retrieving nothing.

This is the code that I have put in my custom module file.

if (module_exists('user')) {
     $username = $form_state['values']['name'];
     $pass = trim($form_state['values']['pass']);
     $userRecord = user_authenticate($username, $pass);

     print_r($userRecord); // its resulting me BLANK!!


Can anybody help me out please? What would the problem be?

  • May you show the complete code of the function that contains the code you shown? – kiamlaluno Jan 26 '12 at 22:05

user_authenticate($name, $pass) (Drupal 7) will return the user ID on successful authentication, or FALSE on failure. In Drupal 6, it will return the user info array.

  • ya i know actually..but thanks for response. can we use emailID instead of $name? – Chandresh Jan 24 '12 at 11:50
  • No, You should pass username to the user_authenticate in drupal 7. – sathishkumar Jan 24 '12 at 11:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.