Notes

It does not check if the user is already a member of the blog before setting their role. If you don't want to overwrite the role of a user if they are already a member of the blog, use is_user_member_of_blog() to check that first.

You do not need to call switch_to_blog() to switch to the blog you want to add the user to before calling this function. The function will switch to the blog itself, and restore the current blog before returning as well.