Change role of indirectly referenced users with Rules I have two content types: Courses and Teachers (with a node reference field between them) and actual users are connected to Teachers with a user reference field. I'd like to assign users to a drupal role when they (the Teacher content they are refered to) refered to a Course.
I can do it easly with a Rule if the node reference field has only one value but I can't cope with multi-value field. 
I have built this rule so far:

{ "rules_oktato_hozzaadas_oktato" : {
"LABEL" : "Oktat\u00f3 hozz\u00e1ad\u00e1sa - oktat\u00f3",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"TAGS" : [ "Oktat\u00f3" ],
"REQUIRES" : [ "rules" ],
"ON" : { "node_update--course" : { "bundle" : "course" } },
"IF" : [
  { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_teacher" } },
  { "OR" : [
      { "entity_has_field" : { "entity" : [ "node:field-teacher:0" ], "field" : "field_related_user" } },
      { "entity_has_field" : { "entity" : [ "node:field-teacher:1" ], "field" : "field_related_user" } },
      { "entity_has_field" : { "entity" : [ "node:field-teacher:2" ], "field" : "field_related_user" } },
      { "entity_has_field" : { "entity" : [ "node:field-teacher:3" ], "field" : "field_related_user" } }
    ]
  }
],
"DO" : [
  { "LOOP" : {
      "USING" : { "list" : [ "node:field-oktato" ] },
      "ITEM" : { "teacher_oktato" : "Tant\u00e1rgy oktat\u00f3i" },
      "DO" : [
        { "drupal_message" : { "message" : "Kurzus oktat\u00f3i: [teacher-oktato:field-related-user]" } }
      ]
    }
  }
]
  }
}


This setup works as I would like to but [tantargy-oktato:field-csatolt-user] is not available in 'change user's role' action. I can choose there only the individual field-teacher entries (:0, :1 etc.)
Finally I managed to solve this issue. The Conditional Rules modul is the key:

{ "rules_oktato_hozzaadas_oktato" : {
"LABEL" : "Oktat\u00f3 hozz\u00e1ad\u00e1sa - oktat\u00f3",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"TAGS" : [ "Oktat\u00f3" ],
"REQUIRES" : [ "rules_conditional", "rules" ],
"ON" : { "node_update--course" : { "bundle" : "course" } },
"DO" : [
  { "LOOP" : {
      "USING" : { "list" : [ "node:field-teacher" ] },
      "ITEM" : { "list_teacher" : "List of teachers" },
      "DO" : [
        { "CONDITIONAL" : [
            {
              "IF" : { "entity_has_field" : { "entity" : [ "list-teacher" ], "field" : "field_related-user" } },
              "DO" : [
                { "user_add_role" : {
                    "account" : [ "list-oktato:field-related-user" ],
                    "roles" : { "value" : { "13" : "13" } }
                  }
                }
              ]
            }
          ]
        }
      ]
    }
  }
]
 }
}