Elgg  Version 6.3
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
29  $user->notify('validate', $user);
30 
31  return elgg_ok_response('', elgg_echo('action:user:validate:success', [$user->getDisplayName()]));
32 });
$user
Definition: ban.php:7
const ELGG_SHOW_DISABLED_ENTITIES
Definition: constants.php:123
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:290
get_input(string $variable, $default=null, bool $filter_result=true)
Parameter input functions.
Definition: input.php:20
get_user(int $guid)
Elgg users Functions to manage multiple or single users in an Elgg install.
Definition: users.php:16
elgg_echo(string $message_key, array $args=[], string $language='')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
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_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.
$user_guid
Validate a user.
Definition: validate.php:6