Set a node field value to a user field's value

Created on 21 December 2023, over 1 year ago
Updated 16 January 2024, about 1 year ago

Problem/Motivation

My users have a field named field_usr_data1 which is a taxonomy term reference. The users have the create new content permission, but cannot edit them after submission. That will be the task of administrators.

My content type has a taxonomy term reference field. Like the user, both fields refer to the same vocabulary.

What I want to do is, whenever the users save the new content, ECA will set a value of the content, the same value of the user's field.

I used set field value action, but in the log there's a message that says access denied, the user must have edit any content permission.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

💬 Support request
Status

Fixed

Version

1.1

Component

Miscellaneous

Created by

🇲🇾Malaysia amal.bukhari

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

Comments & Activities

  • Issue created by @amal.bukhari
  • 🇩🇪Germany jurgenhaas Gottmadingen

    If the current user doesn't have the permission to edit the node, which is what happens when using such an action in an ECA model, then ECA prevents that from happening.

    To resolve this, your model needs to switch the user before making those changes, see User: switch current account

  • 🇲🇾Malaysia amal.bukhari

    Hi,

    I've followed your guide and also on ECA Guide, but I'm getting the error that I cannot change UID when updating content.

    Should it be after saving a new content, or use presave instead?

  • 🇩🇪Germany jurgenhaas Gottmadingen

    Setting the user id is different from what's been described in the issue originally. But still, that should work. Can you please create a simple model without any dependencies, which demonstrates that issue? If that's possible, please export and upload that model for review here to this issue, so that we can find out what's wrong.

  • Status changed to Postponed: needs info over 1 year ago
  • 🇩🇪Germany jurgenhaas Gottmadingen

    Is this being fixed or do you need more support on it?

  • 🇲🇾Malaysia amal.bukhari

    Hi,

    Used the action switch current user, worked wonders! Thanks a lot for the heads up!

    Regards,
    Amal.

  • Status changed to Closed: works as designed over 1 year ago
  • Status changed to Fixed over 1 year ago
  • 🇩🇪Germany jurgenhaas Gottmadingen

    Thanks for your feedback. Marking as fixed, since that's what we need for issue credits.

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

Production build 0.71.5 2024