Elgg  Version 4.x
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 
67 function find_active_users(array $options = []) {
68  return _elgg_services()->usersTable->findActive($options);
69 }
70 
81 function get_online_users(array $options = []) {
82  $options = array_merge([
83  'seconds' => 600,
84  ], $options);
85 
86  return elgg_list_entities($options, 'find_active_users');
87 }
88 
97  return _elgg_services()->passwords->sendNewPasswordRequest($user_guid);
98 }
99 
111  return _elgg_services()->passwords->forcePasswordReset($user_guid, $password);
112 }
113 
123 function execute_new_password_request($user_guid, $conf_code, $password = null) {
124  return _elgg_services()->passwords->executeNewPasswordReset($user_guid, $conf_code, $password);
125 }
126 
133  return _elgg_services()->passwordGenerator->generatePassword();
134 }
135 
151 function register_user($username, $password, $name, $email, $allow_multiple_emails = false, $subtype = null, array $params = []) {
152  return _elgg_services()->accounts->register($username, $password, $name, $email, $allow_multiple_emails, $subtype, $params);
153 }
154 
168 function elgg_validate_registration_data($username, $password, $name, $email, $allow_multiple_emails = false) {
169  return _elgg_services()->accounts->validateAccountData($username, $password, $name, $email, $allow_multiple_emails);
170 }
171 
181  return _elgg_services()->usersTable->generateInviteCode($username);
182 }
183 
195  return _elgg_services()->usersTable->validateInviteCode($username, $code);
196 }
197 
208 function elgg_get_registration_url(array $query = [], $fragment = '') {
209  $url = elgg_generate_url('account:register');
211  return elgg_trigger_plugin_hook('registration_url', 'site', $query, $url);
212 }
213 
223 function elgg_get_login_url(array $query = [], $fragment = '') {
224  $url = elgg_generate_url('account:login');
226  return elgg_trigger_plugin_hook('login_url', 'site', $query, $url);
227 }
228 
240  return _elgg_services()->persistentLogin->getUserFromToken($token);
241 }
force_user_password_reset($user_guid, $password)
Low level function to reset a given user&#39;s password.
Definition: users.php:110
elgg_http_add_url_query_elements($url, array $elements)
Sets elements in a URL&#39;s query string.
Definition: elgglib.php:515
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:168
$user_guid
Definition: login_as.php:10
if(!$user||!$user->canDelete()) $name
Definition: delete.php:22
$username
Definition: delete.php:23
$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
elgg_get_user_by_persistent_token(string $token)
Get a user based on a persistent login token.
Definition: users.php:239
$email
Definition: change_email.php:7
$subtype
Definition: delete.php:22
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:96
$options
Definition: users.php:11
elgg_list_entities(array $options=[], $getter= 'elgg_get_entities', $viewer= 'elgg_view_entity_list')
Returns a string of rendered entities.
Definition: entities.php:589
get_user_by_username($username)
Get user by username.
Definition: users.php:41
register_user($username, $password, $name, $email, $allow_multiple_emails=false, $subtype=null, array $params=[])
Registers a user, returning false if the username already exists.
Definition: users.php:151
generate_invite_code($username)
Generates a unique invite code for a user.
Definition: users.php:180
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
get_online_users(array $options=[])
Render a list of currently online users.
Definition: users.php:81
$token
elgg_get_registration_url(array $query=[], $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:208
generate_random_cleartext_password()
Generate a random 12 character clear text password.
Definition: users.php:132
foreach($plugin_guids as $guid) if(empty($deactivated_plugins)) $url
Definition: deactivate.php:39
_elgg_services()
Get the global service provider.
Definition: elgglib.php:777
elgg_validate_invite_code($username, $code)
Validate a user&#39;s invite code.
Definition: users.php:194
find_active_users(array $options=[])
Return users (or the number of them) who have been active within a recent period. ...
Definition: users.php:67
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:223
$guid
Reset an ElggUpgrade.
Definition: reset.php:6
execute_new_password_request($user_guid, $conf_code, $password=null)
Validate and change password for a user.
Definition: users.php:123