Custom script execution on block and unblock on a user

Hi Team,

We have a requirement , where we want to notify the application when user gets blocked due to brute force login attempts approach and also when user does a self unblock via email ?
Can it be achieved !