'Add role to new user' recipe (a variant of eca_lib_0029)

Created on 11 August 2025, 14 days ago

Problem/Motivation

In the ECA Guide ยป Library ยป Add role to inserted or updated user (eca_lib_0029) an admin cannot remove the content_editor role from an existing user because the model is triggered when saving/updating both new & existing users.

Proposed resolution

Create a variant of eca_lib_0029, and limiting it to new users only, this way if later on an admin decides to remove the automatically assigned role from an existing user, it will work as expected without hidden surprises i.e. the model will not trigger and undo the admin's action.

๐Ÿ’ฌ Support request
Status

Active

Version

3.0

Component

Documentation

Created by

๐Ÿ‡จ๐Ÿ‡ฆCanada bisonbleu

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @bisonbleu
  • ๐Ÿ‡จ๐Ÿ‡ฆCanada bisonbleu

    Attaching the eca.eca.*.yml as per your instructions.
    Let me know if you need this to be done differently.

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany jurgenhaas Gottmadingen

    Thank you @bisonbleu this is now published at https://packagist.org/packages/drupal-eca-recipe/eca_lib_0035

    What I realized is that the improved dependency management that we have in ECA 3.0 takes it a bit too far in this example. My assumption is that the role "content editor" has some permissions, and those get preserved by the recipe. In addition to that, some of the permissions have dependencies themselves as well, which is why we get the page node type and other config entities contained in the recipe as well.

    We may want to look into this separately at some point. For now, I think what's happening is technically correct and determined by config management from Drupal core. But for shareable recipes we may probably change the used roles to something that comes with fewer (or even no) permissions.

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada bisonbleu

    Yeahโ€ฆ I wondered why node.type.article.yml, node.type.page.yml and taxonomy.vocabulary.tags.yml were included in the recipe. I'll keep your comments in mind if I share more recipes.

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany jurgenhaas Gottmadingen
Production build 0.71.5 2024