Here is what I got to but it's not working:

  if ('group_content_hub-group_membership_edit_form' == $form_id) {
    $user = \Drupal::currentUser()->getRoles();
    if (in_array("hub_publisher", $user) && !in_array("administrator", $user)) {
      $form['group_roles']['widget']['#options']['hub-content_publisher']['#disabled'] = TRUE;
      $form['group_roles']['widget']['#options']['hub-hub_admin']['#disabled'] = TRUE;
    }
  }

I also need to change the core role check to a check for current group role, so any help with the function for that would be appreciated as well.

Comments

realityloop created an issue. See original summary.

realityloop’s picture

Title: Way to alter group_content_hub-group_membership_edit_form to disable certain roles from being changed? » Way to alter group_membership_edit_form to disable certain roles from being changed?