Elgg  Version 3.0
requestnewpassword.php
Go to the documentation of this file.
1 <?php
6 $username = get_input('username');
7 
8 // allow email addresses
9 if (strpos($username, '@') !== false && ($users = get_user_by_email($username))) {
10  $username = $users[0]->username;
11 }
12 
14 if (!$user) {
15  return elgg_error_response(elgg_echo('user:username:notfound', [$username]));
16 }
17 
18 if (!send_new_password_request($user->guid)) {
19  return elgg_error_response(elgg_echo('user:password:changereq:fail'));
20 }
21 
22 return elgg_ok_response('', elgg_echo('user:password:changereq:success'), '');
get_user_by_email($email)
Get an array of users from an email address.
Definition: users.php:83
if(strpos($username, '@')!==false &&($users=get_user_by_email($username))) $user
send_new_password_request($user_guid)
Generate and send a password request email to a given user&#39;s registered email address.
Definition: users.php:110
elgg_echo($message_key, array $args=[], $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
get_user_by_username($username)
Get user by username.
Definition: users.php:61
get_input($variable, $default=null, $filter_result=true)
Get some input from variables passed submitted through GET or POST.
Definition: input.php:27
elgg_error_response($error= '', $forward_url=REFERRER, $status_code=ELGG_HTTP_OK)
Prepare an error response to be returned by a page or an action handler.
elgg_ok_response($content= '', $message= '', $forward_url=null, $status_code=ELGG_HTTP_OK)
Prepares a successful response to be returned by a page or an action handler.
$username
Action to request a new password.