Sunday, September 6, 2015

Drupal 7 reset password programmatically

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.

No comments:

Post a Comment