diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php
index 66de3be2cc54b41c5e22eeee6baa4407e704d36f..be81c9b967df90cce7408e2972a01ea592f58f5e 100644
--- a/htdocs/adherents/card.php
+++ b/htdocs/adherents/card.php
@@ -253,7 +253,8 @@ if (empty($reshook))
 		}
 		$lastname=$_POST["lastname"];
 		$firstname=$_POST["firstname"];
-		$morphy=$morphy=$_POST["morphy"];
+		$morphy=$_POST["morphy"];
+		$login=$_POST["login"];
 		if ($morphy != 'mor' && empty($lastname)) {
 			$error++;
 			$langs->load("errors");
@@ -264,7 +265,14 @@ if (empty($reshook))
 			$langs->load("errors");
 			setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Firstname")), null, 'errors');
 		}
-
+		// Test si le login existe deja
+		if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
+		{
+			if (empty($login)) {
+				$error++;
+				setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Login")), null, 'errors');
+			}
+		}
 		// Create new object
 		if ($result > 0 && ! $error)
 		{
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 3287ac5d4b7ab147acc777281d0bbbadf3ff7a2d..c26251f231253741fb81f22a0307ca2a58faa381 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -744,7 +744,8 @@ abstract class CommonObject
 
         $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_contact";
         $sql.= " WHERE element_id = ".$this->id;
-        $sql.= " AND fk_c_type_contact IN (".$listId.")";
+        if ($listId)
+        	$sql.= " AND fk_c_type_contact IN (".$listId.")";
 
         dol_syslog(get_class($this)."::delete_linked_contact", LOG_DEBUG);
         if ($this->db->query($sql))