Elgg  Version 3.0
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  return elgg_ok_response('', elgg_echo('action:user:validate:success', [$user->getDisplayName()]));
29 });
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:1176
get_user($guid)
Get a user object from a GUID.
Definition: users.php:40
elgg_echo($message_key, array $args=[], $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
$user_guid
Validate a user.
Definition: validate.php:6
const ELGG_SHOW_DISABLED_ENTITIES
Definition: constants.php:158
get_input($variable, $default=null, $filter_result=true)
Get some input from variables passed submitted through GET or POST.
Definition: input.php:27
elgg_error_response($error= '', $forward_url=REFERRER, $status_code=ELGG_HTTP_OK)
Prepare an error response to be returned by a page or an action handler.
$user
Definition: ban.php:7
elgg_ok_response($content= '', $message= '', $forward_url=null, $status_code=ELGG_HTTP_OK)
Prepares a successful response to be returned by a page or an action handler.