Skip to content

hook_civicrm_alterSettingsMetaData

Summary

This hook is called when Settings have been loaded from the xml. It is an opportunity for hooks to alter the data.

Definition

alterSettingsMetaData(array &$settingsMetaData, int $domainID, $profile)

Parameters

  • @param array $settingsMetaData Settings Metadata.
  • @param int $domainID
  • @param mixed $profile

Example

/**
 * Implements hook_civicrm_alterSettingsMetaData(().
 *
 * This hook sets the default for each setting to our preferred value.
 * It can still be overridden by specifically setting the setting.
 *
 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_alterSettingsMetaData/
 */
function example_civicrm_alterSettingsMetaData(array &$settingsMetaData, int $domainID, $profile) {
  $configuredSettingsFile = __DIR__ . '/Managed/Settings.php';
  $configuredSettings = include $configuredSettingsFile;
  foreach ($configuredSettings as $name => $value) {
    $settingsMetaData[$name]['default'] = $value;
  }
}