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 thecivicrm_uf_join.modulename they record (e.g.'Profile' => ts('Standalone Form')).
Returns¶
- null
Notes¶
- Each entry in
$ufGroupTypesappears 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_joinrecord. - Core only creates or deletes
civicrm_uf_joinrecords for modules declared in$ufGroupTypes. Joins managed by components (such asCiviEvent) or other extensions not listed in$ufGroupTypeswill 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');
}
}