I have a simple plugin I've created that performs some additional checks after a person has logged in to determine if they are allowed to access the site. It uses the wp_login hook to do so.
That functionality is working fine: we run our check and if they are not allowed to access the site, we call wp_logout().
But if they are denied access, I redirect them (wp_redirect) back to the registration/login page and want to inject a message on screen informing them why they are not allowed access. But I'm having a very difficult time figuring out a way to do that.
I've tried enqueuing a script (wp_enqueue_script) after the redirection. I've also tried injecting an inline script via the wp_footer hook. But nothing is working out. I think the problem is that I don't have the ability to impact the page I'm being redirected to (even though the script doesn't exit after wp_redirect unless I explicitly do so).
What is the best way to handle this post-redirect js injection? (I want to handle this with js/jquery so I can target the element where I want to insert the message.)