Elgg  Version master
delete.php
Go to the documentation of this file.
1 <?php
9 // Get the user
10 $guid = (int) get_input('guid');
12  return elgg_error_response(elgg_echo('admin:user:self:delete:no'));
13 }
14 
16  return get_user($guid);
17 });
18 if (!$user || !$user->canDelete()) {
19  return elgg_error_response(elgg_echo('admin:user:delete:no'));
20 }
21 
22 $name = $user->getDisplayName();
23 $username = $user->username;
24 
26  return $user->delete();
27 });
28 if (!$deleted) {
29  return elgg_error_response(elgg_echo('admin:user:delete:no'));
30 }
31 
32 // forward to user administration if on a user's page as it no longer exists
33 $forward = get_input('forward_url');
34 if (empty($forward)) {
36 
37  if (elgg_strpos($_SERVER['HTTP_REFERER'], $username) !== false) {
38  $forward = 'admin/users';
39  }
40 } else {
42 }
43 
44 return elgg_ok_response('', elgg_echo('admin:user:delete:yes', [$name]), $forward);
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
$deleted
Definition: delete.php:25
if(!$deleted) $forward
Definition: delete.php:33
elgg_normalize_site_url(string $unsafe_url)
From untrusted input, get a site URL safe for forwarding.
Definition: output.php:160
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_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
$username
Definition: delete.php:23
get_input(string $variable, $default=null, bool $filter_result=true)
Parameter input functions.
Definition: input.php:20
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 REFERRER
Used in calls to forward() to specify the browser should be redirected to the referring page...
Definition: constants.php:37
const ELGG_SHOW_DISABLED_ENTITIES
Definition: constants.php:132
elgg_strpos()
Wrapper function for mb_strpos().
Definition: mb_wrapper.php:71
get_user(int $guid)
Elgg users Functions to manage multiple or single users in an Elgg install.
Definition: users.php:16
if($guid===elgg_get_logged_in_user_guid()) $user
Definition: delete.php:15
$guid
Delete a user.
Definition: delete.php:10
elgg_get_logged_in_user_guid()
Return the current logged in user by guid.
Definition: sessions.php:34