diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index fb48539e46735..452bd835d11ce 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -646,6 +646,9 @@ public function create($user, $notrigger = 0) } } + // setEntity will set entity with the right value if empty or change it for the right value if multicompany module is active + $this->entity = setEntity($this); + $this->db->begin(); // Insert member @@ -658,7 +661,7 @@ public function create($user, $notrigger = 0) $sql .= ", ".($user->id > 0 ? $user->id : "null"); // Can be null because member can be created by a guest or a script $sql .= ", null, null, '".$this->db->escape($this->morphy)."'"; $sql .= ", ".((int) $this->typeid); - $sql .= ", ".$conf->entity; + $sql .= ", ".((int) $this->entity); $sql .= ", ".(!empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null"); $sql .= ", ".(!empty($this->ip) ? "'".$this->db->escape($this->ip)."'" : "null"); $sql .= ")"; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 08041134de3e4..9af01fe74ced5 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -508,7 +508,8 @@ public function create($user, $notrigger = 0) $this->statut = 0; // This is to convert '' into '0' to avoid bad sql request } - $this->entity = ((isset($this->entity) && is_numeric($this->entity)) ? $this->entity : $conf->entity); + // setEntity will set entity with the right value if empty or change it for the right value if multicompany module is active + $this->entity = setEntity($this); $sql = "INSERT INTO ".MAIN_DB_PREFIX."socpeople ("; $sql .= " datec";