How to automatically set the ADMINISTRATOR option for the creator of a group?
I've tried to modify the function og_entity_insert(EntityInterface $entity) as follows:
if (!Og::getMembership($entity, $entity->getOwner(), OgMembershipInterface::ALL_STATES)) { $membership = Og::createMembership($entity, $entity->getOwner()); // Get the roles $roles = $membership->getRoles(); foreach ($roles as $rid) { $role = Role::load($rid); if (!$role->isAdmin()) { $role->setIsAdmin(TRUE); } $role->save(); } $membership->setRoles($roles); $membership->save();
But without success. The roles can't be converted to string ...
I'm not a developer. So I do not really understand, what happens and I'm not able to figure out, where the ADMINISTATOR option is added to the members profile and how to activate it.
In my configuration a possibility to activate this option manually is not preset for normal registered users. So if one creates a group, it should automatically be activated, in the meaning, that the group creator is automatically the group administrator.
Version: 8.x-1.0-alpha7, Drupal 9