Skip to content
This repository has been archived by the owner on Aug 18, 2024. It is now read-only.

How to automatically set the ADMINISTRATOR option for the creator of a group? #737

Open
schoenid opened this issue Feb 19, 2022 · 0 comments

Comments

@schoenid
Copy link

schoenid commented Feb 19, 2022

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant