1

I followed the instructions included in the answer to the question "How to implement the mass operations on the Group's members page using Views?". The 2 Rules Components in it (to either block or unblock a member), work fine (and my VBO view shows the mass operations that use those 2 Rules Components).

Now I want to create similar Rules Components for some of the other typical mass update operations, related to members and/or roles (as used in the context of the Group module).

Below are the 2 Rules Components (in Rules export format) I created for this so far:

1. Add a role to the selected members:

{ "rules_add_role_a_group_membership" : {
    "LABEL" : "Add role a group membership",
    "PLUGIN" : "rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : { "group_mbrship" : { "label" : "Group membership", "type" : "group_membership" } },
    "IF" : [
      { "NOT data_is" : {
          "data" : [ "group-mbrship:roles" ],
          "value" : { "value" : { "group_admin" : "group_admin" } }
        }
      }
    ],
    "DO" : [
      { "data_set" : {
          "data" : [ "group-mbrship:roles" ],
          "value" : { "value" : { "group_admin" : "group_admin" } }
        }
      }
    ]
  }
}

This Rules Component should implement the equivalent of the Update option "Add role to selected members" (as shown on group/gid/member, with gid=group id).

2. Delete the role of the selected members:

{ "rules_remove_role_a_group_membership" : {
    "LABEL" : "Remove role a group membership",
    "PLUGIN" : "rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : { "group_mbrship" : { "label" : "Group membership", "type" : "group_membership" } },
    "IF" : [
      { "data_is" : {
          "data" : [ "group-mbrship:roles" ],
          "value" : { "value" : { "group_admin" : "group_admin" } }
        }
      }
    ],
    "DO" : [
      { "data_set" : { "data" : [ "group-mbrship:roles" ], "value" : { "value" : [] } } }
    ]
  }
}

This Rules Component should implement the equivalent of the Update option "Remove role from selected members" (as shown on group/gid/member, with gid=group id).

When I add or remove a role, the following error displays :

enter image description here

I have a problem with the confirmation of action display :

enter image description here

  • @Pierre.Vriens I can not rectify the error. Are my components correct? Thank you – user54067 Nov 22 '16 at 17:44
  • Bonjour Mathieu! No they are NOT correct, I think. Because what you're trying to do, is to add (or remove) a role from a list of roles. And that (for 'add') needs to be done with "Add an item to a list", and not "Set a data value". I have made a little progress to fabricate an appropriate Rules Component, but still "something" still causes some bizarre error (which I don't understand). And I start to wonder if it is even possible to combine such Rules Component with a VBO-view about "memberships". Did you notice there is 1 VBO action for each ROLE to add, or to delete? Why is that? – Pierre.Vriens Nov 22 '16 at 17:55
  • Hey Mathieu, about your last comment: even though you only use 1 role, the type of the field(s) where that role is to be added is still a list. So therefor it can also never work with "Set a data value". So I'm pretty sure it has to be done with "Add an item to a list". FYI: more feedback (maybe an answer?) when I made relevant progress to get it to work ... – Pierre.Vriens Nov 23 '16 at 9:57
  • @Pierre.Vriens Thanks for the information I updated the components. Everything happens correctly but the role is not applied. I encounter another problem (see the last screenshot in the question), indeed the confirmation message seems to be in plain text. – user54067 Nov 23 '16 at 11:07
  • Aha, about your "Everything happens correctly but the role is not applied": that's exactly how far I am myself in my own setup/experiments (= it does not cause any error or produce any msg, but if I then check the user's role nothing seem to have happened ...grrrrrrrr). Which is why I've now started to look for some other type of "entity" (instead of group membership) that needs to be created via the Rules Component. My best guess for now is something related to the "Group Role" for now. I will need more time for more experiments about all this, so sorry "for now" ... – Pierre.Vriens Nov 23 '16 at 11:13

Your Answer

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