Created
September 23, 2013 02:39
-
-
Save scarstens/6665912 to your computer and use it in GitHub Desktop.
Force user to login before accessing the site (on WordPress)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //force user login, regardless of post type | |
| //UNLESS public is in the URL | |
| add_action('parse_request', 'rr_login_redirect'); | |
| function rr_login_redirect() { | |
| global $wp; | |
| if(stristr($wp->request,'public/') || stristr($wp->request,'/public')){} | |
| elseif (!is_user_logged_in()) { | |
| auth_redirect(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment