Skip to content

hook_civicrm_buildProfile

Summary

This hook is called while preparing a profile form. This form allows for extension authors to add various scripts onto the profile pages. Note that hook_civicrm_buildForm is not fired for profile pages

Definition

buildProfile($profileName)

Parameters

  • $profileName - the (machine readable) name of the profile.

Returns

  • null

Example

function myext_civicrm_buildProfile($profileName) {
  if ($profileName === 'MyTargetedProfile) {
    Civi::resources()->addScriptFile('org.example.myext', 'some/fancy.js', 100);
  }
}

Drupal 8+

On Drupal 8+ the only supported region for the Drupal user edit page is form-bottom, e.g.

function myext_civicrm_buildProfile($profileName) {
  if ($profileName === 'MyTargetedProfile) {
    Civi::resources()->addScriptFile('org.example.myext', 'some/fancy.js', 100, 'form-bottom');
  }
}