public function delete() { if (!panel()->user()->isAdmin() and !$this->isCurrent()) { throw new Exception(l('users.delete.error.permission')); } if ($this->isLastAdmin()) { // check the number of left admins to not delete the last one throw new Exception(l('users.delete.error.lastadmin')); } parent::delete(); kirby()->trigger('panel.user.delete', $this); }
public function delete() { if (!panel()->user()->isAdmin() and !$this->isCurrent()) { throw new Exception(l('users.delete.error.permission')); } if ($this->isLastAdmin()) { // check the number of left admins to not delete the last one throw new Exception(l('users.delete.error.lastadmin')); } parent::delete(); // flush the cache in case if the user data is // used somewhere on the site (i.e. for profiles) kirby()->cache()->flush(); kirby()->trigger('panel.user.delete', $this); }