Elgg  Version 4.x
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, 'mail');
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:731
$params
Saves global plugin settings.
Definition: save.php:13
get_user($guid)
Get a user object from a GUID.
Definition: users.php:20
$site
Definition: icons.php:3
elgg_echo($message_key, array $args=[], $language="")
Elgg language module Functions to manage language and translations.
Definition: languages.php:18
notify_user($to, $from=0, $subject= '', $message= '', array $params=[], $methods_override=null)
Notify a user via their preferences.
$user_guid
Validate a user.
Definition: validate.php:6
const ELGG_SHOW_DISABLED_ENTITIES
Definition: constants.php:148
get_input($variable, $default=null, $filter_result=true)
Parameter input functions.
Definition: input.php:20
$user
Definition: ban.php:7
$body
Definition: useradd.php:61
elgg_get_site_entity()
Get the current site entity.
Definition: entities.php:99
elgg_error_response($message= '', $forward_url=REFERRER, int $status_code=ELGG_HTTP_BAD_REQUEST)
Prepare an error response to be returned by a page or an action handler.
elgg_ok_response($content= '', $message= '', $forward_url=null, int $status_code=ELGG_HTTP_OK)
Prepares a successful response to be returned by a page or an action handler.
$subject
Definition: useradd.php:60