How can I redirect to home when user click on back

2019-09-13 10:44发布

问题:

I was wondering how can I redirect users to my hompage after they logged out when they hit the back button, kind of like facebook does. I was playing around with some javascript but nothing seemed to work.

PS: This will be for a Wordpress theme.

回答1:

Hi there check the wp_logout_url($redirect_url).



回答2:

If you use sessions, you can check if the user is logged in when viewing an authenticated page, and if not, send the headers to your homepage.



回答3:

Javascript seems like the way to do it. Simply check if the user is logged and if not, do a redirect to the home page via a document.location = "http://my.home.page";

I guess that you have the session in PHP too so you could just do the redirect there instead of relying on Javascript.

header ('Location: http://your.home.page');