diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 2fb8eea45f6..1939e1709c3 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -690,18 +690,19 @@ class Form
/**
* Return combo list of activated countries, into language of user
*
- * @param string $selected Id or Code or Label of preselected country
- * @param string $htmlname Name of html select object
- * @param string $htmloption More html options on select object
- * @param integer $maxlength Max length for labels (0=no limit)
- * @param string $morecss More css class
- * @param string $usecodeaskey ''=Use id as key (default), 'code3'=Use code on 3 alpha as key, 'code2"=Use code on 2 alpha as key
- * @param int $showempty Show empty choice
- * @param int $disablefavorites 1=Disable favorites,
- * @param int $addspecialentries 1=Add dedicated entries for group of countries (like 'European Economic Community', ...)
- * @return string HTML string with select
+ * @param string $selected Id or Code or Label of preselected country
+ * @param string $htmlname Name of html select object
+ * @param string $htmloption More html options on select object
+ * @param integer $maxlength Max length for labels (0=no limit)
+ * @param string $morecss More css class
+ * @param string $usecodeaskey ''=Use id as key (default), 'code3'=Use code on 3 alpha as key, 'code2"=Use code on 2 alpha as key
+ * @param int $showempty Show empty choice
+ * @param int $disablefavorites 1=Disable favorites,
+ * @param int $addspecialentries 1=Add dedicated entries for group of countries (like 'European Economic Community', ...)
+ * @param array $exclude_country_code Array of country code (iso2) to exclude
+ * @return string HTML string with select
*/
- public function select_country($selected = '', $htmlname = 'country_id', $htmloption = '', $maxlength = 0, $morecss = 'minwidth300', $usecodeaskey = '', $showempty = 1, $disablefavorites = 0, $addspecialentries = 0)
+ public function select_country($selected = '', $htmlname = 'country_id', $htmloption = '', $maxlength = 0, $morecss = 'minwidth300', $usecodeaskey = '', $showempty = 1, $disablefavorites = 0, $addspecialentries = 0, $exclude_country_code = array())
{
// phpcs:enable
global $conf, $langs, $mysoc;
@@ -733,6 +734,7 @@ class Form
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
+
$countryArray[$i]['rowid'] = $obj->rowid;
$countryArray[$i]['code_iso'] = $obj->code_iso;
$countryArray[$i]['code_iso3'] = $obj->code_iso3;
@@ -765,6 +767,7 @@ class Form
{
//if (empty($showempty) && empty($row['rowid'])) continue;
if (empty($row['rowid'])) continue;
+ if (is_array($exclude_country_code) && count($exclude_country_code) && in_array($row['code_iso'], $exclude_country_code)) continue; // exclude some countries
if (empty($disablefavorites) && $row['favorite'] && $row['code_iso']) $atleastonefavorite++;
if (empty($row['favorite']) && $atleastonefavorite)