Hide A Fieldgroup On A Node Display

Public

This is a code for my tutorial here: http://timonweb.com/programmatically-hiding-a-fieldgroup-on-a-node-displ...

Let's you hide a given fieldgroup on a node display

Get raw version
php
  1. /**
  2.  * Implements hook_preprocess_HOOK().
  3.  */
  4. function MODULE_NAME_preprocess_node(&$variables) {
  5. if ($variables['uid'] != 1) {
  6. // You can call this variable any way you want, just put it into $variables['element'] and set as TRUE.
  7. $variables['element']['hide_admin_field_group'] = TRUE;
  8. }
  9. }
  10.  
  11. /**
  12.  * Hide admin field group on a node display.
  13.  */
  14. function MODULE_NAME_field_group_build_pre_render_alter(&$element) {
  15. if (isset($element['hide_admin_field_group']) && isset($element['hide_admin_field_group'])) {
  16. $element['hide_admin_field_group']['#access'] = FALSE;
  17. }
  18. }