Elgg  Version 5.1
validate.php
Go to the documentation of this file.
1 <?php
6 $user_guid = (int) get_input('user_guid');
7 if (empty($user_guid)) {
8  return elgg_error_response(elgg_echo('error:missing_data'));
9 }
10 
11 return elgg_call(ELGG_SHOW_DISABLED_ENTITIES, function() use ($user_guid) {
13  if (empty($user)) {
14  return elgg_error_response(elgg_echo('error:missing_data'));
15  }
16 
17  if ($user->isValidated()) {
18  // already validated
19  return elgg_ok_response('', elgg_echo('action:user:validate:already', [$user->getDisplayName()]));
20  }
21 
22  $user->setValidationStatus(true, 'manual');
23 
24  if ($user->isValidated() !== true) {
25  return elgg_error_response(elgg_echo('action:user:validate:error', [$user->getDisplayName()]));
26  }
27 
28  // inform user about validation
30  $subject = elgg_echo('user:notification:validate:subject', [$site->getDisplayName()], $user->getLanguage());
31  $body = elgg_echo('user:notification:validate:body', [
32  $site->getDisplayName(),
33  $site->getURL(),
34  ], $user->getLanguage());
35 
36  $params = [
37  'action' => 'validate',
38  'object' => $user,
39  'apply_muting' => false,
40  ];
41 
42  notify_user($user->guid, $site->guid, $subject, $body, $params, 'email');
43 
44  return elgg_ok_response('', elgg_echo('action:user:validate:success', [$user->getDisplayName()]));
45 });
elgg_call(int $flags, Closure $closure)
Calls a callable autowiring the arguments using public DI services and applying logic based on flags...
Definition: elgglib.php:299
$params
Saves global plugin settings.
Definition: save.php:13
elgg_ok_response($content= '', string|array $message= '', string $forward_url=null, int $status_code=ELGG_HTTP_OK)
Prepares a successful response to be returned by a page or an action handler.
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
$site
Definition: icons.php:5
get_input(string $variable, $default=null, bool $filter_result=true)
Parameter input functions.
Definition: input.php:20
$user_guid
Validate a user.
Definition: validate.php:6
elgg_error_response(string|array $message= '', string $forward_url=REFERRER, int $status_code=ELGG_HTTP_BAD_REQUEST)
Prepare an error response to be returned by a page or an action handler.
const ELGG_SHOW_DISABLED_ENTITIES
Definition: constants.php:132
$user
Definition: ban.php:7
$body
Definition: useradd.php:55
elgg_get_site_entity()
Get the current site entity.
Definition: entities.php:98
get_user(int $guid)
Elgg users Functions to manage multiple or single users in an Elgg install.
Definition: users.php:16
notify_user(int|array $to, int $from=0, string $subject= '', string $message= '', array $params=[], $methods_override=null)
Notify a user via their preferences.
$subject
Definition: useradd.php:54