Event listener for group change?


So, I'm very very new to coding with xenforo so feel free to provide as much detail as possible :)

Basically, I want to run some code when a user's group is changed(irregardless of how it is changed)

I'm assuming I need to create a listener(Need help doing this)
Also assuming I need to create a class that the listener adds to the group change event(Not sure how to do this)
I will also need to get the following from the user:
Their new group
A custom field value

And I don't know how to do either of those either.

I'm not new to PHP though, so just the most simple example should get me going, thanks!