This project is not covered by Drupal’s security advisory policy.

This module enforces mutual exclusion between configured pairs of Flag flags on the same entity. When a user sets flag A on an entity, flag B is automatically unset, and vice versa.

Features

The Flag module does not natively enforce mutual exclusion between flags. This module adds that capability by listening to Flag's ENTITY_FLAGGED event and automatically unset the counterpart flag when one flag in a configured pair is set.

Common use case: like/dislike reactions where a user can hold only one at a time. Any number of pairs can be configured, across any entity types and any flags that Flag supports.

Post-installation instructions are summarized below, additional documentation is contained in the module’s README file.

Post-Installation

1. Navigate to Administration → Structure → Flags(/admin/structure/flags) and add two flags that are intended to work in tandem. Make a note of their names, and the Entity to which they're configured to apply.

2. Navigate to Configuration → Content authoring → Flag mutually exclusive
(/admin/config/content/flag-mutually-exclusive) and click Add pair.

Setting Description
Label Human-readable name, e.g. "Like / Dislike"
Machine name Unique identifier, auto-generated from the label
Flag A First flag in the pair
Flag B Second flag in the pair — setting either flag unsets the other
Entity type Machine name of the entity type the flags are configured to apply
Enabled Uncheck to temporarily disable without deleting

Configuration is exported as part of flag_mutually_exclusive.settings`and
is included in drush config:export / drush config:import deployments.

Additional Requirements

- Drupal ^11.3
- flag:flag (>=5.0.0)

Similar projects

Rules can be used to configure this functionality. However Rules is heavyweight, this module targets a specific set of functionality that managed Flags on entities in a specific manner, and provides that functionality without the overhead of Rules.

Supporting this Module

This module is supported by Lisa Harrison (lisa.rae), an individual contributor and long-time member of the Drupal community.

Project information

Releases