Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

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?

Thanks

share|improve this question

1 Answer 1

up vote 17 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

 
discard

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.