List Field to Contain a value

Created on 17 March 2024, 9 months ago
Updated 2 April 2024, 9 months ago

Problem/Motivation

I have a content type "Forum", which has a filed "field_ref_user". For each node in "Forum", only users in "field_ref_user" will have access to that node.

So I use ECA:

  • Event triggered by preparing to view the content
  • Compare whether "field_ref_user" contains the current user
  • if yes, continue; if not, redirect

But I cannot find a command to check whether a list field contains one value. Please advice. If you don't have this command yet, do you plan to add it in?

Regards,

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

💬 Support request
Status

Fixed

Version

2.0

Component

Code

Created by

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

Comments & Activities

  • Issue created by @sdsc
  • 🇩🇪Germany jurgenhaas Gottmadingen

    There is the List: contains item condition which will be coming to ECA 2.0

  • Thank you for your reply! Will look forward to that function!

    Another issue I found is: even if I set the event of viewing an entity, and check conditions afterwards, the code only works for once, which means when I refresh the site, the code will not be kicked in. I'll have to clear the cache to get the code working again. Not sure whether it is ECA related or Drupal core related, feels like the cache prevents rechecking viewing an entity.

  • Status changed to Fixed 9 months ago
  • 🇩🇪Germany jurgenhaas Gottmadingen

    It's not a good idea, to ask follow-up questions in issues. Please start new ones for new topics, otherwise the issue can't be helpful for others of when searching for a solution later on.

    ... the code only works for once, which means when I refresh the site, the code will not be kicked in

    That's the purpose of caching. You don't want your Drupal site to execute all code over and over again. Therefore, when Drupal can deliver a cached page, it won't get to the point where it dispatches all the events.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024