Drupal Answers is a question and answer site for Drupal developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a native mobile application communicate with my drupal 7 site via services module. I'd like to give users the ability to reset their password from the app. Is there a way to initiate this process programmatically, so a an email is generated with a one time use token that expires in 24 hours?


share|improve this question
up vote 19 down vote accepted

You can use the _user_mail_notify() function, along with a user object, to invoke the password reset email:

// Load a user (admin in this case).
$account = user_load(1);

// Invoke the email. It will be queued along with other system mail to be sent during cron
_user_mail_notify('password_reset', $account);

A one time login URL with a 24 hour expiry is included by default with that particular email.

share|improve this answer
Sorry. I haven't tested this yet. The feature I was going to use it for was pushed back one release, so I'll be doing this sometime this month. I imagine it'll work since it seems very straightforward. Thanks. – lkiss80 Apr 16 '12 at 21:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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