delete.php 954 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /**
  3. * Delete a user.
  4. *
  5. * The user will be deleted recursively, meaning all entities
  6. * owned or contained by the user will also be removed.
  7. *
  8. * @package Elgg.Core
  9. * @subpackage Administration.User
  10. */
  11. // Get the user
  12. $guid = get_input('guid');
  13. $user = get_entity($guid);
  14. if ($guid == elgg_get_logged_in_user_guid()) {
  15. register_error(elgg_echo('admin:user:self:delete:no'));
  16. forward(REFERER);
  17. }
  18. $name = $user->name;
  19. $username = $user->username;
  20. if (($user instanceof ElggUser) && ($user->canEdit())) {
  21. if ($user->delete()) {
  22. system_message(elgg_echo('admin:user:delete:yes', array($name)));
  23. } else {
  24. register_error(elgg_echo('admin:user:delete:no'));
  25. }
  26. } else {
  27. register_error(elgg_echo('admin:user:delete:no'));
  28. }
  29. // forward to user administration if on a user's page as it no longer exists
  30. $forward = REFERER;
  31. if (strpos($_SERVER['HTTP_REFERER'], $username) != FALSE) {
  32. $forward = "admin/users/newest";
  33. }
  34. forward($forward);