Assigning a role in code isn't working
Your code seems fine. Maybe you could add an additional condition to see if your role argument is proper:

$role_name = 'Role to add'; // The name of the role to add.
  if ($role = user_role_load_by_name($role_name)) {
    user_multiple_role_edit(array($user-&gt;uid), 'add_role', $role-&gt;rid);
  }


I would try adding this condition to make sure all arguments are as intended. Maybe 6 is not a valid index? With this extra condition you will be sure.

Hope this helps, cheers!