I have a website that has two groups - teachers and students. There is a student login page that is public and a teacher login page as well. Both use the Login add-on.
If any user logs into either form, they will be logged in, but if a student tries to login via the teachers portal, they get pushed out to a generic page since they dont have permission for the teacher section. I would much rather they be pushed back to the login page with the error ’This login for teachers only’.
Currently I have a posthook that grabs their user_id from session, checks what group they are in, and if they are a student, I return false and destroy their session. The only thing is, the Login add-on won’t display errors that I save in a posthook, only a prehook.
How do I get errors to diplay from a posthook? Or is there a way to access the user information in the prehook and kick them out then?