public function removeUser($user_guid = 0, $notify_message = "") { $result = false; if (empty($user_guid)) { $user_guid = elgg_get_logged_in_user_guid(); } if (!empty($user_guid)) { // check if this user is not an admin of this site if (!$this->isAdmin($user_guid)) { // get the user for further use $user = get_user($user_guid); // remove the user from the subsite ACL remove_user_from_access_collection($user_guid, $this->getACL()); $result = parent::removeUser($user_guid); // update member_count $this->getMembers(array("count" => true, "force_update_member_count" => true)); // remove the user from every group on this site $options = array("relationship" => "member", "relationship_guid" => $user_guid, "type" => "group", "limit" => false, "site_guid" => $this->getGUID()); // exclude invited groups global $SUBSITE_MANAGER_INVITED_GROUPS; if (!empty($SUBSITE_MANAGER_INVITED_GROUPS)) { $options["wheres"] = array("e.guid NOT IN (" . implode(",", $SUBSITE_MANAGER_INVITED_GROUPS) . ")"); } if ($groups = elgg_get_entities_from_relationship($options)) { foreach ($groups as $group) { $group->leave($user); } } // remove optional membership requests $this->removeMembershipRequests($user_guid); // do we need to notify the user about this if (elgg_is_logged_in() && $user_guid != elgg_get_logged_in_user_guid()) { $admin = elgg_get_logged_in_user_entity(); $subject = elgg_echo("subsite_manager:subsite:remove_user:subject", array($this->name)); $message = elgg_echo("subsite_manager:subsite:remove_user:message", array($user->name, $admin->name, $this->name, $notify_message)); notify_user($user->getGUID(), $admin->getGUID(), $subject, $message, array(), "email"); } } } return $result; }