Reference

user.changeRole:before

$user, $role

Example

/site/config/config.php
return [
    'hooks' => [
        'user.changeRole:before' => function ($user, $role) {
            // your code goes here
        }
    ]
]