Roles Machine name instead of role id
just make sure when you move your roles that you spell them the same!
then you can use the traditional

// Load the currently logged in user.
global $user;

// Check if the user has the 'editor' role.
if (in_array('editor', $user-&gt;roles)) {
  // do fancy stuff
}


or the more flamboyant

function user_has_role($roles) {
    //checks if user has role/roles
    return !!count(array_intersect(is_array($roles)? $roles : array($roles), array_values($GLOBALS['user']-&gt;roles)));
};

if (user_has_role(array('moderator', 'administrator'))) {
  // $user is admin or moderator
}


see here for more answers to the simple question Check if a user has a role