I want to override the value for "allow_insecure_uploads" which is in system.file config, but only for specific roles. Am I going to need to do this in a module / does one already exist?


Module suggestions are usually frowned upon on DA, but regardless the answer is yes; role-specific config values are possible via the D8 config override system.

The Drupal 8 docs has a section on the config override system with a relevant example in the Providing overrides from modules section. After you've declared the override class in your module's .services.yml & created the override PHP class, you'll do something like this in the loadOverrides() method:

 public function loadOverrides($names) {
    $overrides = array();
    // @TODO: define a hasRole($role) class method that checks Drupal::currentUser() for a given role
    $has_role = $this->hasRole('my_role');
    if (in_array('system.file', $names) && $has_role) {
      $overrides['system.file'] = ['allow_insecure_uploads' => TRUE];
    return $overrides;

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.