Skip to content

Add role to inserted or updated user

Version v3

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/eca_lib_0029
cd web && php core/scripts/drupal recipe ../vendor/drupal-eca-recipe/eca_lib_0029

Purpose

This model demonstrates how to add a role to an inserted or updated user entity. There are actually 3 potential ways of doing this, only 1 of them being recommended. The recorded session (see link below) shows the issues you can run into when choosing one of the other options and it may become transparent, why the third option is the best of the available ones.

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

Dependencies

  • module
    • eca_base
    • eca_content
    • eca_user

Used plugins

Events

Conditions

Actions

Changelog

v1

Initial version

v2

Clean-up the model

v3

Do not save entity as this model acts in pre-save event