2

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!!
     exit;

   }

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

1
  • May you show the complete code of the function that contains the code you shown?
    – avpaderno
    Commented Jan 26, 2012 at 22:05

1 Answer 1

2

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.

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

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.