Different roles depending on a user's field I have a problem that I have not a clear idea of how to solve it, the problem is the following: We have a user form registration where there's a mandatory field that is Country. I have also a content type that is called mobility that has a field, incoming country (among others). The thing is that now, I have to make that only users of for example USA, can modify the contents where USA is the incoming country. 

I've seen that this could be "done" by just allowing a user from a certain country to view the USA contents but it's not the perfect approach since when I'm in a link like "../content/id/edit" i could try different id's and be able to modify a content that I would not be able theoretically. The only way I see to do it "well" would be to do some approach like having one role for each country but is not scalable. 

Any solid approach to solve this problem?

PD: I can't solve it by IP (there's a module) because this user when (s)he registers, choose the country that is from (explaining why would be a bit long but it's a correct approach for what we are looking for)
You should be able to do this with a custom module and without roles. There is plenty of documentation around for creating custom modules, so I will not go into those details.

In your .module file, make use of hook_node_access:

function MODULENAME_node_access($node, $op, $account) {
  $type = is_string($node) ? $node : $node-&gt;type;

  // Only work on edits.
  if ($type == 'contry_content_type' &amp;&amp; $op == 'edit') {
    // Field get items returns an array.
    $user_countries = field_get_items('user', $account, 'country_field_name');
    $content_countries = field_get_items('node', $node, 'node_country_field_name');

    if ($user_countries[0] == content_countries[0]) {
        return NODE_ACCESS_ALLOW;
    }
  }

  // Returning nothing from this function would have the same effect.
  return NODE_ACCESS_IGNORE;
}