Group Flex Joining Methods
The availability of the group joining method on the GroupType and Group are based on the available plugin implementations. With a plugin implementation you can expose a joining method to the Group Flex module. None of the logic of the actual joining should be handled within this plugin.
By default these joining methods are provided by the module:
- "Join" button
This is the default joining method provided by the Group module. If an outsider clicks on the "Join" button the Group Membership is created directly or after filling in all the required Group Membership fields. - "Request"
This joining method is provided by the Group Membership Request module and only available if this module is installed. An outsider can request membership to the group and a Group Administrator can either accept or reject the request. - "Invite by email"
This joining method is provided by the Group Invite module and only available if this module is installed. A member of the group can invite other users (or people without an account) to join the group. The user can accept or decline the invite. The Group Administrator has an overview at which they can manage invites.
You can create your own joining method plugin to expose any joining method. A custom plugin implementation is needed since there is no generic way to create group memberships for the Group module and thus no way for the Group Flex module to automatically detect these. A joining method can be an implementation of the GroupContentEnabler Plugin (Group membership request or Group membership) or might as well be some custom code triggered by an external CRM which creates a Group membership directly. Exposing joining methods as a plugin makes it possible for developers to enable any joining method in the Group Flex system for their site.
Permissions and custom roles
Except for the "call to action" method, the joining methods correspond to permissions set for the Member role, the OOTB role provided by the "Group" module. For example if you deselect the "Invite users" joining method, then the permission is revoked for the Member role. For the "call to action" method you can choose which roles have access to it.
This means it is not automatically revoked for any custom group roles, nor will it be automatically granted if it the joining method is enabled. This is in particular the case when the group owner can select the joining method(s) for their group.
When you create a custom group role for a group type, you are responsible for the permissions you set for the joining methods. Even if the "Invite users" joining methods is not enabled by the group owner, this role will still have access to inviting users.
Example Plugin Implementation
Example plugins can be found in src/Plugin/GroupJoiningMethod.
The 'join_button' group joining method has the following:
- id: the id of the join method plugin (string)
- label: the label of the join method (translatable string)
- weight: the weight of the join method (integer)
This weight can be used to change the order of the display of the joining methods in the UI. - visibility_options: an array of visibility options (array)
This defines on which visibility options the joining method should be available. In this example we don't want the "Join" button when the Group is private.
<?php
namespace Drupal\group_flex\Plugin\GroupJoiningMethod;
use Drupal\group\Entity\GroupInterface;
use Drupal\group\Entity\GroupTypeInterface;
use Drupal\group_flex\Plugin\GroupJoiningMethodBase;
/**
* Provides a 'join_button' group joining method.
*
* @GroupJoiningMethod(
* id = "join_button",
* label = @Translation("Call to action (join button)"),
* weight = -100,
* visibilityOptions = {
* "public",
* "flex"
* }
* )
*/
class JoinButton extends GroupJoiningMethodBase {
/**
* {@inheritdoc}
*/
public function enableGroupType(GroupTypeInterface $groupType) {
$mappedPerm = [$groupType->getOutsiderRoleId() => ['join group' => TRUE]];
$this->saveMappedPerm($mappedPerm, $groupType);
}
/**
* {@inheritdoc}
*/
public function disableGroupType(GroupTypeInterface $groupType) {
$mappedPerm = [$groupType->getOutsiderRoleId() => ['join group' => FALSE]];
$this->saveMappedPerm($mappedPerm, $groupType);
}
/**
* {@inheritdoc}
*/
public function getGroupPermissions(GroupInterface $group) {
return [
$group->getGroupType()->getOutsiderRoleId() => ['join group'],
];
}
/**
* {@inheritdoc}
*/
public function getDisallowedGroupPermissions(GroupInterface $group) {
return [
$group->getGroupType()->getOutsiderRoleId() => ['join group'],
];
}
}
Documentation on the functions can be found in src/Plugin/GroupJoiningMethodInterface.php.
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion