You can also fix this problem only with the help of module rules, without coding.
In my case, I wanted to redirect people to my workplace after entering the system. But people who have forgotten their password will also be redirected to their desktop and will not be able to change their password. They had to go to their profile page, but again they had to re-enter the password: peer-to-peer registration no longer worked.
So this is the rule I added:
Events Event: User logged in.
Conditions Elements: text comparison. Parameter: Tekst: [site: current-page: path], Corresponding text: user, Comparison operation: ends with
Actions Elements: page redirection Parameter: URL: admin / workbench, Force redirect: false
source share