Elgg  Version master
unban.php
Go to the documentation of this file.
1 <?php
6 $user_guids = (array) get_input('user_guids');
7 if (empty($user_guids)) {
8  return elgg_error_response(elgg_echo('error:missing_data'));
9 }
10 
11 /* @var $users \ElggBatch */
13  'type' => 'user',
14  'guids' => $user_guids,
15  'limit' => false,
16  'batch' => true,
17  'batch_inc_offset' => false,
18  'metadata_name_value_pairs' => [
19  'banned' => 'yes',
20  ],
21 ]);
22 
23 /* @var $user \ElggUser */
24 $count = 0;
25 foreach ($users as $user) {
26  if ($user->unban()) {
27  $count++;
28  } else {
29  $users->reportFailure();
30  }
31 }
32 
33 return elgg_ok_response('', elgg_echo('action:admin:user:bulk:unban', [$count]));
$user_guids
Bulk unban users.
Definition: unban.php:6
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
get_input(string $variable, $default=null, bool $filter_result=true)
Parameter input functions.
Definition: input.php:20
$count
Definition: unban.php:24
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.
elgg_get_entities(array $options=[])
Fetches/counts entities or performs a calculation on their properties.
Definition: entities.php:507
$user
Definition: ban.php:7
if(empty($user_guids)) $users
Definition: unban.php:12