diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 8c21e4dbfbe..f88560159b0 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -400,9 +400,7 @@ if (empty($reshook)) $object->note_public = (string) GETPOST("note_public", 'restricthtml'); $object->note_private = (string) GETPOST("note_private", 'restricthtml'); - if (GETPOSTISSET("roles")) { - $object->roles = GETPOST("roles", 'array'); - } + $object->roles = GETPOST("roles", 'array'); // Note GETPOSTISSET("role") is null when combo is empty // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index b4555ba4dfd..075e44deead 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1747,14 +1747,14 @@ class Contact extends CommonObject if (count($this->roles) > 0) { foreach ($this->roles as $keyRoles => $valRoles) { $idrole = 0; - if (is_array($idrole)) { + if (is_array($valRoles)) { $idrole = $valRoles['id']; } else { $idrole = $valRoles; } $socid = 0; - if (is_array($idrole)) { + if (is_array($valRoles)) { $socid = $valRoles['socid']; } else { $socid = $this->socid;