Elgg  Version 4.3
users.php
Go to the documentation of this file.
1 <?php
10 
20 function get_user($guid) {
21  try {
22  return _elgg_services()->entityTable->get($guid, 'user');
23  } catch (InvalidParameterException $ex) {
24  elgg_log($ex, 'ERROR');
25 
26  return false;
27  } catch (ClassException $ex) {
28  elgg_log($ex, 'ERROR');
29 
30  return false;
31  }
32 }
33 
42  return _elgg_services()->usersTable->getByUsername($username);
43 }
44 
53  return _elgg_services()->usersTable->getByEmail($email);
54 }
55 
66  _elgg_services()->passwords->requestNewPassword($user);
67 }
68 
80 function elgg_save_new_password(\ElggUser $user, string $conf_code, string $password = null): bool {
81  return _elgg_services()->passwords->saveNewPassword($user, $conf_code, $password);
82 }
83 
91 function elgg_generate_password(): string {
92  return _elgg_services()->passwordGenerator->generatePassword();
93 }
94 
111 function elgg_register_user(array $params = []): \ElggUser {
112  return _elgg_services()->accounts->register($params);
113 }
114 
128 function elgg_validate_registration_data($username, $password, $name, $email, $allow_multiple_emails = false) {
129  return _elgg_services()->accounts->validateAccountData($username, $password, $name, $email, $allow_multiple_emails);
130 }
131 
141 function elgg_generate_invite_code(string $username): string {
142  return _elgg_services()->usersTable->generateInviteCode($username);
143 }
144 
156  return _elgg_services()->usersTable->validateInviteCode((string) $username, (string) $code);
157 }
158 
170 function elgg_get_registration_url(array $parameters = [], $fragment = ''): string {
171  $url = elgg_generate_url('account:register', $parameters) . $fragment;
172 
173  return (string) elgg_trigger_plugin_hook('registration_url', 'site', $parameters, $url);
174 }
175 
185 function elgg_get_login_url(array $query = [], $fragment = '') {
186  $url = elgg_generate_url('account:login');
188  return elgg_trigger_plugin_hook('login_url', 'site', $query, $url);
189 }
190 
202  return _elgg_services()->persistentLogin->getUserFromToken($token);
203 }
elgg_http_add_url_query_elements($url, array $elements)
Sets elements in a URL&#39;s query string.
Definition: elgglib.php:481
elgg_validate_registration_data($username, $password, $name, $email, $allow_multiple_emails=false)
Assert that given registration details are valid and can be used to register the user.
Definition: users.php:128
$params
Saves global plugin settings.
Definition: save.php:13
get_user($guid)
Get a user object from a GUID.
Definition: users.php:20
Elgg registration action.
get_user_by_email($email)
Get an array of users from an email address.
Definition: users.php:52
if(!$user||!$user->canDelete()) $name
Definition: delete.php:22
elgg_generate_password()
Generate a random 12 character clear text password.
Definition: users.php:91
elgg_save_new_password(\ElggUser $user, string $conf_code, string $password=null)
Validate and change password for a user.
Definition: users.php:80
elgg_get_user_by_persistent_token(string $token)
Get a user based on a persistent login token.
Definition: users.php:201
elgg_register_user(array $params=[])
Registers a user.
Definition: users.php:111
c Accompany it with the information you received as to the offer to distribute corresponding source complete source code means all the source code for all modules it plus any associated interface definition plus the scripts used to control compilation and installation of the executable as a special the source code distributed need not include anything that is normally and so on of the operating system on which the executable unless that component itself accompanies the executable If distribution of executable or object code is made by offering access to copy from a designated then offering equivalent access to copy the source code from the same place counts as distribution of the source even though third parties are not compelled to copy the source along with the object code You may not or distribute the Program except as expressly provided under this License Any attempt otherwise to sublicense or distribute the Program is void
Definition: LICENSE.txt:215
$email
Definition: change_email.php:7
$username
Definition: delete.php:23
get_user_by_username($username)
Get user by username.
Definition: users.php:41
elgg_get_registration_url(array $parameters=[], $fragment= '')
Returns site&#39;s registration URL Triggers a &#39;registration_url&#39;, &#39;site&#39; plugin hook that can be used by...
Definition: users.php:170
A generic parent class for Class exceptions.
if(!$user||!$user->canEdit()) $password
elgg_log($message, $level=\Psr\Log\LogLevel::NOTICE)
Log a message.
Definition: elgglib.php:399
elgg_generate_url($name, array $parameters=[])
Generate a URL for named route.
elgg_trigger_plugin_hook($hook, $type, $params=null, $returnvalue=null)
Definition: elgglib.php:380
$query
Definition: users.php:8
$user
Definition: users.php:11
$token
elgg_generate_invite_code(string $username)
Generates a unique invite code for a user.
Definition: users.php:141
foreach($plugin_guids as $guid) if(empty($deactivated_plugins)) $url
Definition: deactivate.php:39
elgg_request_new_password(\ElggUser $user)
Generate and send a password request email to a given user&#39;s registered email address.
Definition: users.php:65
_elgg_services()
Get the global service provider.
Definition: elgglib.php:638
elgg_validate_invite_code($username, $code)
Validate a user&#39;s invite code.
Definition: users.php:155
elgg_get_login_url(array $query=[], $fragment= '')
Returns site&#39;s login URL Triggers a &#39;login_url&#39;, &#39;site&#39; plugin hook that can be used by plugins to al...
Definition: users.php:185
$guid
Reset an ElggUpgrade.
Definition: reset.php:6