public function Group::addMember in Group 8
Same name and namespace in other branches
- 2.0.x src/Entity/Group.php \Drupal\group\Entity\Group::addMember()
Adds a user as a member of the group.
Does nothing if the user is already a member of the group.
Parameters
\Drupal\user\UserInterface $account: The user entity to add as a member.
array $values: (optional) Extra values to add to the group membership, like the 'group_roles' field. You cannot overwrite the group ID (gid) or user ID (entity_id) with this method. Leave blank to make the user just a member.
Overrides GroupInterface::addMember
1 call to Group::addMember()
- Group::postSave in src/
Entity/ Group.php - Acts on a saved entity before the insert or update hook is invoked.
File
- src/
Entity/ Group.php, line 190
Class
- Group
- Defines the Group entity.
Namespace
Drupal\group\EntityCode
public function addMember(UserInterface $account, $values = []) {
if (!$this
->getMember($account)) {
$this
->addContent($account, 'group_membership', $values);
}
}