I have a rules action component that I use in VBO to flag users with a punish flag. The punish flag has a reason long text field.

In rules, the component is an action set that consists of the action Flag a user. However, the Flag a user action does not include an option to set the value of any of the flagging fields (in this case, reason).

I want to somehow set the reason field when I evaluate this component. My first thought was to create another rule that triggers on the event When a user is flagged, but this does not work in my case because the flag can be triggered multiple ways, and the value of reason should be different in each case. (This was suggested here.)

So, I want to somehow access the flagging that is created by the Flag a user action and then change the value of reason, but I don't see any obvious way of doing that in rules other than making a loop that goes through all the flaggings on the site and looks for the one that affects the relevant user.

Is there a clean way to grab a flagging set by a rules component and then set the value of a field for that flagging?

  • Interesting question (challenge!). 2 clarification requests: (a) How many different "reasons" can that field have for your punish flag? Only a few, dozens or hundreds? (b) Who decides about the allowed reasons (only a few admins, or all sorts of users)? – Pierre.Vriens Nov 2 '15 at 14:17
  • The "reason" field is a text field, so it can be an arbitrary number. When assigned by the rules component, the value for reason will be a canned response, but when an admin flags a user individually, the admin can type whatever is appropriate for that specific user. Only admins/the site itself can flag. – Patrick Kenny Nov 2 '15 at 14:31
  • No sure if it makes sense, but to get around that "the flag can be triggered multiple ways" (and use your first thought anyway), you might want to consider either of these approaches: (a) create a new/other flag (so that you can separate it from those "other ways") or (b) use a TEMP flag, which in your additional rule you then unset again, and replace it by a set of the same flag you already have. – Pierre.Vriens Nov 2 '15 at 14:40
  • Still curious to any type of feedback about my prior comment. Apart from that, how about you implement that "reason field" as an extra field related to the user account (instead of a field related to the flag)? With that, I would think it might be possible (haven't experimented with it yet) to set that reason field as an additional rules action (apart from flagging the user). – Pierre.Vriens Nov 5 '15 at 18:42
  • @Pierre.Vriens These are interesting ideas that may work in other use cases, but I specifically want to know how to create a flagging and assign one of its fields a specific value. Since there seems to be no good way to do this in Rules, I am now looking at just doing it in PHP. – Patrick Kenny Nov 6 '15 at 7:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.