diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 2e2534621b1..e995fc03001 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -375,6 +375,7 @@ if (empty($reshook)) { $editgroup->oldcopy = clone $editgroup; $object->fetch($id); + if ($action == 'addgroup') { $result = $object->SetInGroup($group, $editgroup->entity); } diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 65a7b7d7842..9e208ff3e37 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2651,7 +2651,11 @@ class User extends CommonObject $sql = "DELETE FROM ".$this->db->prefix()."usergroup_user"; $sql .= " WHERE fk_user = ".((int) $this->id); $sql .= " AND fk_usergroup = ".((int) $group); - $sql .= " AND entity = ".((int) $entity); + if (empty($entity)) { + $sql .= " AND entity IN (0, 1)"; // group may be in entity 0 (so $entity=0) and link with user into entity 1. + } else { + $sql .= " AND entity = ".((int) $entity); + } $result = $this->db->query($sql); if ($result) {