Elgg  Version master
email.php
Go to the documentation of this file.
1 <?php
9 if (!$user instanceof \ElggUser) {
10  return;
11 }
12 
13 $fields = [];
14 
15 if (elgg_get_config('security_email_require_password') && ($user->guid === elgg_get_logged_in_user_guid())) {
16  // user needs to provide current password in order to be able to change his/her email address
17  $fields[] = [
18  '#type' => 'password',
19  '#label' => elgg_echo('email:address:password'),
20  '#help' => elgg_echo('email:address:password:help'),
21  'name' => 'email_password',
22  'autocomplete' => 'current-password',
23  ];
24 }
25 
26 $email_help = null;
27 if (elgg_get_config('security_email_require_confirmation') && isset($user->new_email)) {
28  $email_help = elgg_echo('email:address:help:confirm', [$user->new_email]);
29 }
30 
31 $fields[] = [
32  '#type' => 'email',
33  '#label' => elgg_echo('email:address:label'),
34  '#help' => $email_help,
35  'name' => 'email',
36  'value' => $user->email,
37 ];
38 
39 if (count($fields) === 1) {
40  echo elgg_view_field($fields[0]);
41  return;
42 }
43 
44 echo elgg_view_field([
45  '#type' => 'fieldset',
46  'legend' => elgg_echo('email:settings'),
47  'fields' => $fields,
48 ]);
$vars['class']
Elgg email input Displays an email input field.
Definition: email.php:9
elgg_view_field(array $params=[])
Renders a form field, usually with a wrapper element, a label, help text, etc.
Definition: views.php:1112
elgg_get_config(string $name, $default=null)
Get an Elgg configuration value.
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
if(elgg_get_config('security_email_require_password')&&($user->guid===elgg_get_logged_in_user_guid())) $email_help
Definition: email.php:26
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:254
elgg_get_page_owner_entity()
Gets the owner entity for the current page.
Definition: pageowner.php:23
if(!$user instanceof\ElggUser) $fields
Definition: email.php:13
$user
Provide a way of setting your email.
Definition: email.php:8
elgg_get_logged_in_user_guid()
Return the current logged in user by guid.
Definition: sessions.php:34