Since not all emacs commands and features bring there own hook, you need to extend the given function.
One way is to use
advice-add which can do all sorts of manipulation. (i.e filter function arguments, modify return values, call functions befor, after, etc). It is easy to apply and universal usable throughout emacs. For detailed information please look at the doc string of
It can be used that way:
(defun my-flyspell-goto-next-error-do-stuff (&rest r)
(do some funky stuff))
(add-function 'flyspell-goto-next-error :after #'my-flyspell-goto-next-error-do-stuff)
Another way would be to copy the original function code, manipulate it as needed and define it as the new function.
There is one problem with that approach, if the original function changes for some reason (bugfix, improved features), you keep working with the old version and nothing gives you a hint about the change. It might happen that this introduces some weird behaviour on your config. There exist packages like el-patch, which address this issue.
I thought: both methods need to be installed after the original functionality has been loaded.
with-eval-after-load can help you there.
But user Phils said otherwise in its comment below (forward advice).
I did not (yet) test this. In any case: you should be on the safe side if you install the advice after loading.