Skip to content
This repository was archived by the owner on Aug 18, 2024. It is now read-only.
This repository was 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

@schoenid

Description

@schoenid

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions