User roles are changing automatically

Good catch with the action, catching the instance.

You might be able to add a debug_backtrace() to trace it back to the calling functions, and their calling functions, to see how you actually get there.

error code: 523