If you are changing someone team with a plugin, you already know when they change teams (when you execute the function; which you are not doing correctly BTW).
If you want helpful advice, you should explain in detail of what you are actually trying to do.