diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php
index 93305dbc63cbe81f4880c12f7fdfd1db11714d5a..d829f2194df72b40d79600965312c53cc17731e2 100644
--- a/htdocs/projet/activity/perday.php
+++ b/htdocs/projet/activity/perday.php
@@ -108,6 +108,35 @@ if ($action == 'assign')
     {
     	$idfortaskuser=$user->id;
 		$result = $object->add_contact($idfortaskuser, GETPOST("type"), 'internal');
+
+    	if ($result >= 0 || $result == -2)	// Contact add ok or already contact of task
+    	{
+			// Test if we are already contact of the project (should be rare but sometimes we can add as task contact without being contact of project, like when admin user has been removed from contact of project)
+    		$sql='SELECT ec.rowid FROM '.MAIN_DB_PREFIX.'element_contact as ec, '.MAIN_DB_PREFIX.'c_type_contact as tc WHERE tc.rowid = ec.fk_c_type_contact';
+    		$sql.=' AND ec.fk_socpeople = '.$idfortaskuser." AND ec.element_id = '.$object->fk_project.' AND tc.element = 'project' AND source = 'internal'";
+    		$resql=$db->query($sql);
+    		if ($resql)
+    		{
+    			$obj=$db->fetch_object($resql);
+    			if (! $obj)	// User is not already linked to project, so we will create link to first type
+    			{
+    				$project = new Project($db);
+    				$project->fetch($object->fk_project);
+    				// Get type
+    				$listofprojcontact=$project->liste_type_contact('internal');
+    				
+    				if (count($listofprojcontact))
+    				{
+    					$typeforprojectcontact=reset(array_keys($listofprojcontact));
+    					$result = $project->add_contact($idfortaskuser, $typeforprojectcontact, 'internal');
+    				}
+    			}
+    		}
+    		else 
+    		{
+    			dol_print_error($db);
+    		}
+    	}
     }
 
 	if ($result < 0)
diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php
index 6201c601d180145de2f6ef21f2ac2f9d07243289..40cc9248b9f9168187e1840abecf93dbf0d9bd09 100644
--- a/htdocs/projet/activity/perweek.php
+++ b/htdocs/projet/activity/perweek.php
@@ -119,7 +119,36 @@ if ($action == 'assign')
     if (! $error)
     {
     	$idfortaskuser=$user->id;
-		$result = $object->add_contact($idfortaskuser, GETPOST("type"), 'internal');
+    	$result = $object->add_contact($idfortaskuser, GETPOST("type"), 'internal');
+
+    	if (! $result || $result == -2)	// Contact add ok or already contact of task
+    	{
+    		// Test if we are already contact of the project (should be rare but sometimes we can add as task contact without being contact of project, like when admin user has been removed from contact of project)
+    		$sql='SELECT ec.rowid FROM '.MAIN_DB_PREFIX.'element_contact as ec, '.MAIN_DB_PREFIX.'c_type_contact as tc WHERE tc.rowid = ec.fk_c_type_contact';
+    		$sql.=' AND ec.fk_socpeople = '.$idfortaskuser." AND ec.element_id = '.$object->fk_project.' AND tc.element = 'project' AND source = 'internal'";
+    		$resql=$db->query($sql);
+    		if ($resql)
+    		{
+    			$obj=$db->fetch_object($resql);
+    			if (! $obj)	// User is not already linked to project, so we will create link to first type
+    			{
+    				$project = new Project($db);
+    				$project->fetch($object->fk_project);
+    				// Get type
+    				$listofprojcontact=$project->liste_type_contact('internal');
+    				
+    				if (count($listofprojcontact))
+    				{
+    					$typeforprojectcontact=reset(array_keys($listofprojcontact));
+    					$result = $project->add_contact($idfortaskuser, $typeforprojectcontact, 'internal');
+    				}
+    			}
+    		}
+    		else 
+    		{
+    			dol_print_error($db);
+    		}
+    	}
     }
 
 	if ($result < 0)