How to hide group settings on node edit forms

Last updated on
30 April 2025

If you want to control how group members create and interact with group content through other means than the group settings on the node edit form (or just allow admin users to change what group content is in), it can be useful to hide that setting. One way to do this is to create a custom module and use this code that hides the form for all users except those with role id 5 (replace HOOK with your module name):

function HOOK_form_node_form_alter(&$form, &$form_state, $form_id) {
  $node = $form['#node'];
  // Form alters per content type.
  switch ($node->type) {
    case 'event':
      global $user;
      // Hide group settings for all except community managers
      if (!(user_has_role(5, $user))) {
        $form['group_settings']['#access'] = FALSE;
      }
      break;
  }
}

Help improve this page

Page status: Not set

You can: