Elgg  Version 4.3
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)) {
35  $forward = REFERER;
36 
37  if (elgg_strpos($_SERVER['HTTP_REFERER'], $username) !== false) {
38  $forward = 'admin/users/newest';
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:592
$deleted
Definition: delete.php:25
get_user($guid)
Get a user object from a GUID.
Definition: users.php:20
if(!$deleted) $forward
Definition: delete.php:33
if(!$user||!$user->canDelete()) $name
Definition: delete.php:22
elgg_normalize_site_url($unsafe_url)
From untrusted input, get a site URL safe for forwarding.
Definition: output.php:166
$username
Definition: delete.php:23
elgg_echo($message_key, array $args=[], $language="")
Elgg language module Functions to manage language and translations.
Definition: languages.php:18
const ELGG_SHOW_DISABLED_ENTITIES
Definition: constants.php:148
get_input($variable, $default=null, $filter_result=true)
Parameter input functions.
Definition: input.php:20
elgg_strpos()
Wrapper function for mb_strpos().
Definition: mb_wrapper.php:69
if($guid===elgg_get_logged_in_user_guid()) $user
Definition: delete.php:15
const REFERER
Definition: constants.php:52
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.
$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