removeadmin.php 605 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. /**
  3. * Revokes admin privileges from a user.
  4. *
  5. * @package Elgg.Core
  6. * @subpackage Administration.User
  7. */
  8. $guid = get_input('guid');
  9. $user = get_entity($guid);
  10. if ($guid == elgg_get_logged_in_user_guid()) {
  11. register_error(elgg_echo('admin:user:self:removeadmin:no'));
  12. forward(REFERER);
  13. }
  14. if (($user instanceof ElggUser) && ($user->canEdit())) {
  15. if ($user->removeAdmin()) {
  16. system_message(elgg_echo('admin:user:removeadmin:yes'));
  17. } else {
  18. register_error(elgg_echo('admin:user:removeadmin:no'));
  19. }
  20. } else {
  21. register_error(elgg_echo('admin:user:removeadmin:no'));
  22. }
  23. forward(REFERER);