When any page is viewed, I need to make sure that the user ID is in a custom database table, and if the id is not present there, I want to log the user out and not allow him to see any content. I also want to display a custom message on the login page saying “You are not authorised to see this blog.”
I tried doing this with some of the wp logout/redirect functions, but I want this to be automatic on all pages across the wp site. Also I don’t know how to sent the custom message to the login page. I guess I could just set a POST value or something like that and modify the login page to check if that value is present.
Any help or tips on how to do this properly would be appreciated.
Try following
Put the code below in your theme templates.
Put following in your function.php