Elgg  Version 5.1
delete.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 
12  foreach ($user_guids as $user_guid) {
13  $user = get_user($user_guid);
14  if (empty($user)) {
15  continue;
16  }
17 
18  $name = $user->getDisplayName();
19  if ($user->delete()) {
20  elgg_register_success_message(elgg_echo('admin:user:delete:yes', [$name]));
21  } else {
22  elgg_register_error_message(elgg_echo('entity:delete:fail', [$name]));
23  }
24  }
25 });
26 
27 return elgg_ok_response();
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
$user_guid
Definition: login_as.php:10
if(!$user||!$user->canDelete()) $name
Definition: delete.php:22
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_register_success_message(string|array $options)
Registers a success system message.
Definition: elgglib.php:43
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
$user_guids
Bulk delete users.
Definition: delete.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
get_user(int $guid)
Elgg users Functions to manage multiple or single users in an Elgg install.
Definition: users.php:16
elgg_register_error_message(string|array $options)
Registers a error system message.
Definition: elgglib.php:62
if($guid===elgg_get_logged_in_user_guid()) $user
Definition: delete.php:15