Skip to content

hook_civicrm_ufGroupTypes

Summary

This hook is called when enumerating the ways a profile can be exposed. It allows extensions to register custom profile exposure options (civicrm_uf_join.module), or alter existing exposure options.

Availability

This hook is available in CiviCRM 6.20+.

Definition

hook_civicrm_ufGroupTypes(array &$ufGroupTypes)

Parameters

  • array &$ufGroupTypes - associative array of labels keyed by the civicrm_uf_join.module name they record (e.g. 'Profile' => ts('Standalone Form')).

Returns

  • null

Notes

  • Each entry in $ufGroupTypes appears as an "Expose To" checkbox on the profile settings form.
  • When a profile settings form is saved, checking or unchecking the box creates or deletes the corresponding civicrm_uf_join record.
  • Core only creates or deletes civicrm_uf_join records for modules declared in $ufGroupTypes. Joins managed by components (such as CiviEvent) or other extensions not listed in $ufGroupTypes will not be removed when the profile form is saved.
  • Hooks can also relabel existing types provided by core or CMS integrations.

Example

Registering a new exposure option

/**
 * Implements hook_civicrm_ufGroupTypes().
 */
function myext_civicrm_ufGroupTypes(array &$ufGroupTypes): void {
  $ufGroupTypes['Contact Summary'] = E::ts('Contact Summary Block');
}

Modifying an existing option label

/**
 * Implements hook_civicrm_ufGroupTypes().
 */
function myext_civicrm_ufGroupTypes(array &$ufGroupTypes): void {
  if (isset($ufGroupTypes['Profile'])) {
    $ufGroupTypes['Profile'] = ts('Standalone Form or Directory');
  }
}