Elgg  Version 3.0
Namespaces | Functions | Variables
users.php File Reference

Go to the source code of this file.

Namespaces

 Elgg\Core
 Updates the advanced settings for the primary site object.
 

Functions

 disable_user_entities ($owner_guid)
 Disables all of a user's entities. More...
 
 get_user ($guid)
 Get a user object from a GUID. More...
 
 get_user_by_username ($username)
 Get user by username. More...
 
 get_user_by_code ($hash)
 Get user by persistent login password. More...
 
 get_user_by_email ($email)
 Get an array of users from an email address. More...
 
 find_active_users (array $options=[])
 Return users (or the number of them) who have been active within a recent period. More...
 
 send_new_password_request ($user_guid)
 Generate and send a password request email to a given user's registered email address. More...
 
 force_user_password_reset ($user_guid, $password)
 Low level function to reset a given user's password. More...
 
 execute_new_password_request ($user_guid, $conf_code, $password=null)
 Validate and change password for a user. More...
 
 generate_random_cleartext_password ()
 Generate a random 12 character clear text password. More...
 
 validate_username ($username)
 Simple function which ensures that a username contains only valid characters. More...
 
 validate_password ($password)
 Simple validation of a password. More...
 
 validate_email_address ($address)
 Simple validation of a email. More...
 
 register_user ($username, $password, $name, $email, $allow_multiple_emails=false, $subtype=null)
 Registers a user, returning false if the username already exists. More...
 
 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. More...
 
 generate_invite_code ($username)
 Generates a unique invite code for a user. More...
 
 elgg_validate_invite_code ($username, $code)
 Validate a user's invite code. More...
 
 elgg_get_registration_url (array $query=[], $fragment= '')
 Returns site's registration URL Triggers a 'registration_url', 'site' plugin hook that can be used by plugins to alter the default registration URL and append query elements, such as an invitation code and inviting user's guid. More...
 
 elgg_get_login_url (array $query=[], $fragment= '')
 Returns site's login URL Triggers a 'login_url', 'site' plugin hook that can be used by plugins to alter the default login URL. More...
 
 elgg_user_hover_menu ($hook, $type, $return, $params)
 Setup the default user hover menu. More...
 
 _elgg_user_title_menu (\Elgg\Hook $hook)
 Adds avatar edit button to title menu. More...
 
 _elgg_user_page_menu ($hook, $type, $return, $params)
 Register menu items for the page menu. More...
 
 _elgg_user_topbar_menu ($hook, $type, $return, $params)
 Register menu items for the topbar menu. More...
 
 _elgg_user_set_icon_file ($hook, $type, $icon, $params)
 Set user icon file. More...
 
 _elgg_user_get_subscriber_unban_action ($hook, $type, $return_value, $params)
 Add the user to the subscribers when (un)banning the account. More...
 
 _elgg_user_ban_notification ($event, $type, $user)
 Send a notification to the user that the account was banned. More...
 
 _elgg_user_prepare_unban_notification ($hook, $type, $return_value, $params)
 Prepare the notification content for the user being unbanned. More...
 
 _elgg_user_unvalidated_menu (\Elgg\Hook $hook)
 Register menu items to the user:unvalidated menu. More...
 
 users_init ()
 Users initialisation function, which establishes the page handler. More...
 

Variables

return function (\Elgg\EventsService $events,\Elgg\HooksRegistrationService $hooks)
 

Function Documentation

_elgg_user_ban_notification (   $event,
  $type,
  $user 
)

Send a notification to the user that the account was banned.

Note: this can't be handled by the delayed notification system as it won't send notifications to banned users

Parameters
string$event'ban'
string$type'user'
\ElggUser$userthe user being banned
Returns
void

Definition at line 610 of file users.php.

_elgg_user_get_subscriber_unban_action (   $hook,
  $type,
  $return_value,
  $params 
)

Add the user to the subscribers when (un)banning the account.

Parameters
string$hook'get'
string$type'subscribers'
array$return_valuecurrent subscribers
array$paramssupplied params
Returns
void|array

Definition at line 574 of file users.php.

_elgg_user_page_menu (   $hook,
  $type,
  $return,
  $params 
)

Register menu items for the page menu.

Parameters
string$hook'register'
string$type'menu:page'
ElggMenuItem[]$return current return value
array$paramssupplied params
Returns
void|ElggMenuItem[]

Definition at line 447 of file users.php.

_elgg_user_prepare_unban_notification (   $hook,
  $type,
  $return_value,
  $params 
)

Prepare the notification content for the user being unbanned.

Parameters
string$hook'prepare'
string$type'notification:unban:user:'
\Elgg\Notifications\Notification$return_valuecurrent notification content
array$paramssupplied params
Returns
void|

Definition at line 648 of file users.php.

_elgg_user_set_icon_file (   $hook,
  $type,
  $icon,
  $params 
)

Set user icon file.

Parameters
string$hook"entity:icon:file"
string$type"user"
\ElggIcon$iconIcon file
array$paramsHook params
Returns

Definition at line 553 of file users.php.

_elgg_user_title_menu ( \Elgg\Hook  $hook)

Adds avatar edit button to title menu.

Parameters
\Elgg\Hook$hookhook 'register', 'menu:title'
Returns
void|ElggMenuItem[]

Definition at line 406 of file users.php.

_elgg_user_topbar_menu (   $hook,
  $type,
  $return,
  $params 
)

Register menu items for the topbar menu.

Parameters
string$hook'register'
string$type'menu:topbar'
ElggMenuItem[]$return current return value
array$paramssupplied params
Returns
void|ElggMenuItem[]

Definition at line 487 of file users.php.

_elgg_user_unvalidated_menu ( \Elgg\Hook  $hook)

Register menu items to the user:unvalidated menu.

register menu:user:unvalidated

Parameters
\Elgg\Hook$hookthe plugin hook 'register' 'menu:user:unvalidated'
Returns
void|ElggMenuItem[]
Since
3.0

Definition at line 692 of file users.php.

disable_user_entities (   $owner_guid)

Disables all of a user's entities.

Parameters
int$owner_guidThe owner GUID
Returns
bool Depending on success

Definition at line 17 of file users.php.

elgg_get_login_url ( array  $query = [],
  $fragment = '' 
)

Returns site's login URL Triggers a 'login_url', 'site' plugin hook that can be used by plugins to alter the default login URL.

Parameters
array$queryAn array of query elements
string$fragmentFragment identifier (e.g. login-dropdown-box)
Returns
string

Definition at line 277 of file users.php.

elgg_get_registration_url ( array  $query = [],
  $fragment = '' 
)

Returns site's registration URL Triggers a 'registration_url', 'site' plugin hook that can be used by plugins to alter the default registration URL and append query elements, such as an invitation code and inviting user's guid.

Parameters
array$queryAn array of query elements
string$fragmentFragment identifier
Returns
string

Definition at line 262 of file users.php.

elgg_user_hover_menu (   $hook,
  $type,
  $return,
  $params 
)

Setup the default user hover menu.

Parameters
string$hook'register'
string$type'menu:user_hover'
ElggMenuItem[]$return current return value
array$paramssupplied params
Returns
void|ElggMenuItem[]

Definition at line 295 of file users.php.

elgg_validate_invite_code (   $username,
  $code 
)

Validate a user's invite code.

Parameters
string$usernameThe username
string$codeThe invite code
Returns
bool
See also
generate_invite_code()
Since
1.10

Definition at line 248 of file users.php.

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.

Parameters
string$usernameThe username of the new user
string | array$passwordThe password Can be an array [$password, $confirm_password]
string$nameThe user's display name
string$emailThe user's email address
bool$allow_multiple_emailsAllow the same email address to be registered multiple times?
Returns

Definition at line 222 of file users.php.

execute_new_password_request (   $user_guid,
  $conf_code,
  $password = null 
)

Validate and change password for a user.

Parameters
int$user_guidThe user id
string$conf_codeConfirmation code as sent in the request email.
string$passwordOptional new password, if not randomly generated.
Returns
bool True on success

Definition at line 137 of file users.php.

find_active_users ( array  $options = [])

Return users (or the number of them) who have been active within a recent period.

Parameters
array$optionsArray of options with keys:

seconds (int) => Length of period (default 600 = 10min) limit (int) => Limit (default from settings) offset (int) => Offset (default 0) count (bool) => Return a count instead of users? (default false)

Returns
[]|int

Definition at line 99 of file users.php.

force_user_password_reset (   $user_guid,
  $password 
)

Low level function to reset a given user's password.

This can only be called from execute_new_password_request().

Parameters
int$user_guidThe user.
string$passwordText (which will then be converted into a hash and stored)
Returns
bool

Definition at line 124 of file users.php.

generate_invite_code (   $username)

Generates a unique invite code for a user.

Parameters
string$usernameThe username of the user sending the invitation
Returns
string Invite code
See also
elgg_validate_invite_code()

Definition at line 234 of file users.php.

generate_random_cleartext_password ( )

Generate a random 12 character clear text password.

Returns
string

Definition at line 146 of file users.php.

get_user (   $guid)

Get a user object from a GUID.

This function returns an from a given GUID.

Parameters
int$guidThe GUID
Returns
|false

Definition at line 40 of file users.php.

get_user_by_code (   $hash)

Get user by persistent login password.

Parameters
string$hashHash of the persistent login password
Returns

Definition at line 72 of file users.php.

get_user_by_email (   $email)

Get an array of users from an email address.

Parameters
string$emailEmail address.
Returns
array

Definition at line 83 of file users.php.

get_user_by_username (   $username)

Get user by username.

Parameters
string$usernameThe user's username
Returns
|false Depending on success

Definition at line 61 of file users.php.

register_user (   $username,
  $password,
  $name,
  $email,
  $allow_multiple_emails = false,
  $subtype = null 
)

Registers a user, returning false if the username already exists.

Parameters
string$usernameThe username of the new user
string$passwordThe password
string$nameThe user's display name
string$emailThe user's email address
bool$allow_multiple_emailsAllow the same email address to be registered multiple times?
string$subtypeSubtype of the user entity
Returns
int|false The new user's GUID; false on failure
Exceptions
RegistrationException

Definition at line 205 of file users.php.

send_new_password_request (   $user_guid)

Generate and send a password request email to a given user's registered email address.

Parameters
int$user_guidUser GUID
Returns
false|array

Definition at line 110 of file users.php.

users_init ( )

Users initialisation function, which establishes the page handler.

Returns
void

Definition at line 734 of file users.php.

validate_email_address (   $address)

Simple validation of a email.

Parameters
string$addressEmail address
Returns
bool
Exceptions
RegistrationException

Definition at line 186 of file users.php.

validate_password (   $password)

Simple validation of a password.

Parameters
string$passwordClear text password
Returns
bool
Exceptions
RegistrationException

Definition at line 173 of file users.php.

validate_username (   $username)

Simple function which ensures that a username contains only valid characters.

This should only permit chars that are valid on the file system as well.

Parameters
string$usernameUsername
Returns
bool
Exceptions
RegistrationException

Definition at line 160 of file users.php.

Variable Documentation

See also
::loadCore Do not do work here. Just register for events.

Definition at line 757 of file users.php.