Skip to content

Instantly share code, notes, and snippets.

@clrockwell
Created September 20, 2016 19:24
Show Gist options
  • Select an option

  • Save clrockwell/22e04de49562d58507f6363160076c5a to your computer and use it in GitHub Desktop.

Select an option

Save clrockwell/22e04de49562d58507f6363160076c5a to your computer and use it in GitHub Desktop.
<?php
/**
* Implements hook_field_extra_fields().
* Add the code to Registration enabled entities
*/
function my_module_field_extra_fields() {
$extra = [];
foreach (entity_get_info() as $entity_type => $entity_info) {
foreach (array_keys($entity_info['bundles']) as $bundle) {
// @todo need review on how reliable this is for getting registration references
$field_instance = field_read_fields([
'entity_type' => $entity_type,
'bundle' => $bundle,
'type' => 'registration',
]);
if (!empty($field_instance)) {
$extra[$entity_type][$bundle]['display']['registration_sms'] = [
'label' => t('Registration SMS code'),
'description' => 'SMS code if user is allowed to see it.',
'weight' => 0,
];
}
}
}
return $extra;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment