diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index aa1a6fb045c..8f57c121108 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -1199,8 +1199,9 @@ class Setup extends DolibarrApi { $list = array(); - if (!DolibarrApiAccess::$user->admin) { - throw new RestException(403, 'Only an admin user can get list of extrafields'); + if (!DolibarrApiAccess::$user->admin + && (!getDolGlobalString('API_LOGINS_ALLOWED_FOR_GET_EXTRAFIELDS') || DolibarrApiAccess::$user->login != getDolGlobalString('API_LOGINS_ALLOWED_FOR_GET_EXTRAFIELDS'))) { + throw new RestException(403, 'Error API open to admin users only or to the users with logins defined into constant API_LOGINS_ALLOWED_FOR_GET_EXTRAFIELDS'); } if ($elementtype == 'thirdparty') {