In my drupal site, I'm using the Group module.

My problem:

  • I created a regular Drupal node type, let's call it userpost
  • I created a group type called "usergroup"
  • The content type "userpost" is also installed as a group node of group type "usergroup"

Is there a way to put a reference field or something similar into my "regular" node form for my content type called userpost? So that it's possible to (optional) relate a node during creation, to one (or more) group(s) at the same time?

In the admin interface of a group it's possible to relate existing content to a group. This kind of reference field I would like to place into my node creation form :)

Thanks for any hint in advance.

Best regards Phil

P.S. I opened for this problem an issue at Drupal.org too.

  • This post is quite similar to my problem: drupal.stackexchange.com/questions/265785/…
    – dercheffe
    Commented Mar 10, 2019 at 11:16
  • I haven't used group module but what you just described is easily achievable by organic groups module drupal.org/project/og. You can set the content type to be either group (parent) or group content (child) or both, then when you create child nodes you can link them to as many groups as necessary with a supplied entity reference field. NB I have done this in Drupal 7 but I would imagine similar settings/behavior on D8. If you're not tied to using group module I'd definitely recommend og.
    – seroton
    Commented Mar 10, 2019 at 16:16

1 Answer 1


Well, if I understand your problem correctly, you could just add an entity_reference field to your node type 'userpost' via admin toolbar. Go to Structure->Content types->userpost->Manage fields->Add field->Choose Reference (other)->Select Group and set cardinality to whatever you want.

This would allow you to add group references when you create a new node of content type userpost

Update What I described adds a reference from a node to one or multiple group(s) via a new field, it does NOT add this node as a group-content to your group(s). It depends what you are trying to achieve? If you want to add your node as a group-content and you want to do this via the node creation form, you need one more extra step. You can implement a hook_ENTITY_TYPE_insert(). From there get the group(s) that you entered to your node field (from $node), $groups = $node->get('field_groups') and add the $node as group_content to each group, similar as done in the answer you linked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.