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?


1 Answer 1


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.

  • 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, 2012 at 21:17

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.