How to assign a user a role during registration using Rules and Profile 2? I am using the Profile 2 module to select roles during the registration process. So a user selects a role (using a radio button) and then a rule fires to give the user the role that was selected.

Here is the rule I'm using:

    { "rules_give_user_a_role_after_registration" : {
    "LABEL" : "Give user a role after registration",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "user_insert" : [] },
    "IF" : [
      { "data_is" : {
          "data" : [ "account:profile-main:field-user-role" ],
          "value" : "Emporos"
        }
      }
    ],
    "DO" : [
      { "user_add_role" : { "account" : [ "account" ], "roles" : { "value" : { "5" : "5" } } } }
    ]
  }
}


The issue is that the role is not assigned to the user. Any idea why not?
If "...the role is not assigned to the user..." (as in your question), it must be that your Rules Action is not performed. And if that's the case, then that must be because your Rules Condition is not satisfied (true).

And the reason why your Rules Condition is not true, is pretty sure because you should add another Rules Condition Entity has field (related to your additional field in the Rules Condition you already have). And make sure to add that Entity has field condition BEFORE the Rules Condition in which you want to perform that "data to compare".

That's also what is mentioned in the Rules UI when you're adding a "data comparison" condition: somewhere it says "The data selector helps you drill down into the data available to Rules. To make entity fields appear in the data selector, you may have to use the condition 'entity has field' (or 'content is of type')".

For a video tutorial that illustrates the importance of this Entity has field condition, refer to Data types and data selection, especially what is shown between about 13:30 and 17:30 in it.