Skip to content

Grant new user role after 3 conditions are met

Version v2

Instead of downloading the archive, you can download and apply this model as a recipe (Drupal 10.3 or later):

1
2
composer require drupal-eca-recipe/grant_new_user_role_after_3_conditions_are_met
cd web && php core/scripts/drupal recipe ../vendor/drupal-eca-recipe/grant_new_user_role_after_3_conditions_are_met

Purpose

This model automatically adds or removes a role from a user, when this gets updated, depending upon 3 conditions that are stored with the user entity. Only if all 3 conditions are met, the role gets added. In all other cases the role gets removed.

The creation of this module was recorded and the video with additional explanations can be watched here.

Dependencies

  • config
    • user.role.moderator
  • module
    • eca_base
    • eca_content
    • user

Used plugins

Events

Conditions

Actions

Changelog

v1

Initial release

v2

Replace role content_moderator with new role moderator to avoid extra dependencies that are derived from permissions