Group Actions

Provides configurable actions for the Group module, enabling bulk operations on group memberships and group content.

group_action
703 sites
20
drupal.org

Install

Drupal 11, 10 v1.2.2
composer require 'drupal/group_action:^1.2'
Drupal 9 v1.1.1
composer require 'drupal/group_action:^1.1'

Overview

Group Actions is a Drupal module that extends the Group module by providing a set of configurable action plugins. These actions allow site administrators and developers to perform bulk operations on group-related entities, such as adding or removing users as group members, and adding, updating, or removing content from groups.

The module is designed to be used in conjunction with other modules that leverage Drupal's action system, such as Views Bulk Operations (VBO) for performing batch operations on views listings, or ECA (Event - Condition - Action) for creating automated workflows triggered by events. The actions support token replacement for dynamic configuration, making them highly flexible for complex automation scenarios.

Group Actions is fully compatible with Group module versions 1.x, 2.x, and 3.x, automatically detecting and adapting to the installed version's API differences.

Features

  • Add users as members to groups with configurable group roles
  • Remove users from group memberships
  • Update existing group memberships with new field values or roles
  • Add content entities (nodes, etc.) to groups as group content
  • Remove content from groups
  • Update group content field values
  • Token support for dynamic configuration of group IDs, entity IDs, and field values
  • Configurable add methods: skip if already added, always add, or update existing
  • Entity autocomplete for group selection in configuration forms
  • Full compatibility with Group module versions 1.x, 2.x, and 3.x
  • ECA module compatibility with special recursion threshold handling

Use Cases

Bulk add users to groups via Views

Create a view of users and use Views Bulk Operations to add the 'Group: add user as member' action. Select multiple users from the view and add them all to a specific group with assigned roles in a single operation.

Automated membership management with ECA

Set up an ECA model that triggers when a user is created or updated. Based on conditions (such as user role or profile field values), automatically add the user to appropriate groups using the 'Group: add user as member' action with token-based configuration.

Content organization workflow

When content is published or updated, automatically add it to relevant groups based on taxonomy terms or other field values. Use ECA with the 'Group: add content' action and tokens to dynamically determine the target group.

Bulk content removal from groups

Use VBO with the 'Group: remove content' action to clean up group content relationships. Useful for reorganizing content between groups or removing outdated content from group listings.

Update group roles in bulk

Select users who are already group members and use the 'Group: update user membership' action with VBO to change their group roles (e.g., promoting members to administrators) in a bulk operation.

Dynamic group assignment based on tokens

Configure actions with token values like [node:field_department:entity:id] to dynamically add content to groups based on entity field values. This enables automatic content routing to appropriate groups without manual configuration.

Tips

  • Use the 'skip_existing' add method (default) to prevent duplicate group relationships when running actions on mixed sets of entities that may already be group members.
  • Configure token-based group IDs to create dynamic workflows where the target group is determined by entity field values rather than hardcoded.
  • When setting group roles via the 'values' field, use the format 'group_roles: grouptype-roleid' where the role ID includes the group type prefix.
  • The entity autocomplete for group selection provides a user-friendly way to select groups during configuration, but you can also enter numeric IDs or UUIDs directly.
  • For ECA models, you can use any entity type's tokens when replacing values, making it possible to look up related entities and use their properties in the configuration.

Technical Details

Troubleshooting 5
Action not appearing in VBO or ECA

Ensure the Group module is properly installed and configured with at least one group type. The action plugins require the Group module's plugin managers to be available.

Permission denied when executing actions

The actions check permissions against the group's permission system. Ensure the user executing the action has the appropriate group permissions (e.g., 'create group_membership content', 'delete group_membership content') for the target group type.

Content plugin not available in action configuration

The content plugin (group relation type) must be installed for the group type. Configure the group type at Administration > Structure > Group types and ensure the desired content plugin is enabled.

Token replacement not working

Verify the token syntax is correct (e.g., [user:uid], [node:nid]). Ensure the Token module is installed if using advanced tokens. Check that the entity being processed provides the expected token context.

ECA workflow stops unexpectedly during group operations

This can occur due to ECA's recursion detection when group operations trigger additional entity saves. The module includes automatic handling for this, but if issues persist, check ECA's recursion threshold settings.

Security Notes 3
  • Actions respect Drupal's group permission system. Users must have appropriate group-level permissions to execute actions on specific groups.
  • Admin users (user 1 and users with admin roles) bypass group permission checks for these actions.
  • Token replacement is performed server-side with proper sanitization, but ensure sensitive data is not exposed through token values in logs or error messages.