Need a script to connect to wifi based on user logged in
I'd say there's no need of complicated solutions.
Every users you created have a completely customizable environment. So, if you go to the System Preferences, Network, choose WiFi on the left (among different types of connections) and then click on the "Advanced" button.
You'll see a list of preferred networks. The items in this list may be simply dragged. The one on the top will be the chosen one, even if there are other wifi networks you previously connected to.
Obviously, you might also decide to delete the other networks, if you are sure you won't use them with that user.