requestnewpassword.php 620 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. /**
  3. * Action to request a new password.
  4. *
  5. * @package Elgg.Core
  6. * @subpackage User.Account
  7. */
  8. $username = get_input('username');
  9. // allow email addresses
  10. if (strpos($username, '@') !== false && ($users = get_user_by_email($username))) {
  11. $username = $users[0]->username;
  12. }
  13. $user = get_user_by_username($username);
  14. if ($user) {
  15. if (send_new_password_request($user->guid)) {
  16. system_message(elgg_echo('user:password:changereq:success'));
  17. } else {
  18. register_error(elgg_echo('user:password:changereq:fail'));
  19. }
  20. } else {
  21. register_error(elgg_echo('user:username:notfound', array($username)));
  22. }
  23. forward();