How to programmatically add content to a group in the Group Module? I'm using the Group module. If I have a group type such as Project, and I have a content type such as Article, and I programmatically created a new article node using Node::create(), how can I in the same code add this article as content to a project that I choose?
Given you have the group entity and node entity, you can simply create a GroupContent entity.

$groupEntity = ... The group entity.
$node = ... The node entity.

$type = $type = $groupEntity-&gt;getGroupType()-&gt;id() . '-group_node-' . $node-&gt;getType();

$groupContentEntity = \Drupal\group\Entity\GroupContent::create([
    'gid' =&gt; $groupEntity-&gt;id(),
    'entity_id' =&gt; $node-&gt;id(),
    'type' =&gt; $type,
]);
$groupContentEntity-&gt;save();